We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Data Structures
  3. Trees
  4. Swap Nodes [Algo]
  5. Discussions

Swap Nodes [Algo]

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 657 Discussions, By:

votes

Please Login in order to post a comment

  • xialin
    6 years ago+ 27 comments

    One of the most ambiguous question on HackerRank. I wish I could down vote the problem description.

    1250|
    Permalink
    View more Comments..
  • stefanks
    7 years ago+ 21 comments

    In python had to change recursion limit to work on the last two test inputs

    import sys sys.setrecursionlimit(15000)

    139|
    Permalink
    View more Comments..
  • pburakov
    6 years ago+ 0 comments

    The problem is not hard at all, but very poor description and badly structured input make it a lot harder than it should be. I would suggest some areas for clarification. Is i the line number? Or is it node index? It's actually both, and the right answer is that null node should not be indexed but line numbers go on. It's not immediately clear if K is applied to depth or height, because below for some reason letter h is used to represent the depth. Use of index in the input and other constrains literally enforce the use of array upon the user.

    70|
    Permalink
  • realq86
    7 years ago+ 2 comments

    Solved the problem but had to. 1. Create node object. 2. Create a breathFirst to read input. 3. Create a depthFirst to change height. 4. Create a Inorder to print.

    Took 3 hours total. Is is listed as "Easy?" Is there an easier way than the apporche I did?

    59|
    Permalink
  • oguzhanyalcin
    5 years ago+ 0 comments

    The worst question I've read....

    53|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature