Sorting Challenges Comments


  • I like the quotes :)
    Just wish it would run code a little faster though

  • The code usually runs in a few seconds (and doesn't display quotes), but sometimes it needs to fall back to a different server.

  • I have implemented binary search by recursion.
    Here is my code:

    static void doStuff(int[] ar){
    //your code here
    int low = 0;
    int high = ar.length-1;

  • 曾國峻 I needed to keep track of the index and pass it back up the recursion to solve it. Because each time the binary search needed to look at the > side of the array, the index forgets about the lower half of the array. Here is my solution in Ruby:

  • Better to solve without recursion. maybe can be a bit more elegant, but works.

        int start = 0;
        int end = ar.length-1;
        int i = start + ((end - start) / 2);
  • If you're looking for code to get started, this Java code converts the input into Tuples, and added a helpful compareTo method to the Tuples.

  • Am I supposed to change the boilerplate code? Can I pass two arrays to doStuff or do I have to combine both lists in one array?

  • @Kendall, you can modify the method however you want. I created boilerplate that does that here:

  • The two arrays don't appear to match up at all on the second run. I printed out the first 10 and they didn't match. What am I missing? Thanks!

  • @Kendall, the numbers are in different orders in each list. You need to find the extra numbers in list B, preferably without sorting the lists. I added another test case to make it clearer.

  • Got it, I interpreted identical lists to mean identical orders. Thanks!

Contact Us
Sign in or email us at [email protected]