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.
Thank you so much. This helped my java solution pass test cases 1 and 2. At first, I thought my issue was that I was using a linear search to find the location to swap instead of a binary search. Even after I implemented the binary search, I timed out. Instead, it was an incomplete understanding of outputing to the standard output that got me. Changing the outputing method to use the OutputStreamWriter changed the runtime for test cases 1 and 2 from both over 4 seconds to just about 1 second.
This post should be higher up.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Bigger is Greater
You are viewing a single comment's thread. Return to all comments →
Thank you so much. This helped my java solution pass test cases 1 and 2. At first, I thought my issue was that I was using a linear search to find the location to swap instead of a binary search. Even after I implemented the binary search, I timed out. Instead, it was an incomplete understanding of outputing to the standard output that got me. Changing the outputing method to use the OutputStreamWriter changed the runtime for test cases 1 and 2 from both over 4 seconds to just about 1 second.
This post should be higher up.