Coding challenge #2 - Win SBD if you solve the problem!

in #contest7 years ago

This is my second contest about coding problems. I find coding problems very interesting and I really enjoy solving them, so I thought: I must not be the only one!

So here I am, writing you some of the problems I found myself working on in job interviews, or competitions I took part in the past.
I hope you enjoy it at much as I do.

This problem is similar to that of last week, but in some way trickier.
Have fun!

Contest #2

In a Linked list, each node has a value and a next node.
Given a Linked list:

  1. Write a function that reverse the linked list, using a recursive algorithm.
  2. Write a function that reverse the linked list, using a iterative algorithm.
    • For instance: given A -> B -> C it returns C -> B ->A

You don't have to clone the nodes, you must just work on their next properties.

The preferred language to use this time is javascript, but you can also use other languages as well. You will need to translate the starting code to the language of your choice.

Rules

  • Submit your solution:
    • Open the starting code (in javascript): https://pastebin.com/tHBtHZVF
      • or create something similar in another language if you prefer
    • Edit the code to solve the challenge. You could use online tools like https://repl.it/languages/javascript to write and test your solution directly in the browser
    • Submit a link to your code on https://steemit.chat by DM @armandocat
      • Specify your steem account name. If you win, I will deposit the prize there.
      • Once I try your code, I may help you with suggestions on how to fix problems or make your code better.
  • You cannot use built in function. You need to work on the linked list at low level (i.e. using for, while, ...)
  • Don't post your solution in the comments. If you do, you will be disqualified. Everyone should work on the problem by himself/herself. I will post the best solutions after the competion is ended.
  • I'm the judge. I'll try to be as objective as possible, but it's possible that the coding style I like could be different from what somebody else likes. However, I make the contest, I decide who wins ;)
  • I have all the rights to disqualify any suspected cheating players.

Rewards

The liquid reward of this post will be divided between the working solution submitted in this way:

  • The most time- and space-efficient, well-written solution will get 50% of the liquid reward of this post
  • The second will get 25%
  • The third will get 12.5%
  • ...
  • Well, let's say that if you end up in nth position, you will get 1/2^n%
  • If two or more solutions are considered a tie, the time the solution is submitted decide how wins (the first solution submitted wins). Or I can decide to split the rewards equally, for instance if two contestant are considered winners, I may sum the 1st and 2nd price and divide the 75% of the liquid reward between the two.

You have 7 days to submit your answer!
Good luck!

Armando 🐾

Sort:  

congrats to the winners

Yay, another coding challenge. Hope you don't mind that I entered again. 🙂

You are more than welcome ;)

@armandocat Your generate up is spectacular. Mad regard for sticking as a result of many of the hardships, Many of us would've Give up A great deal before. Upvoted.

I am a bot!

Solution Submitted

Submitted

Cool another coding challenge!