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.
It takes me lots of time to solve this challenge, so I have to write something to share with you bothered by it:
a. ascending and descending sequence of the data will influence the swap times. So your method needs to be called twice and then you choose the smaller swap times as your answer.
b. Consider the small circles of data, which might affect the swap times. for example, 0>2, 2>1, 1>0, 3->4, 4>5, 5>3, totally there are 4 swaps, but my first try uses another simple method which gets 5 swaps and that is wrong.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Lily's Homework
You are viewing a single comment's thread. Return to all comments →
It takes me lots of time to solve this challenge, so I have to write something to share with you bothered by it:
a. ascending and descending sequence of the data will influence the swap times. So your method needs to be called twice and then you choose the smaller swap times as your answer. b. Consider the small circles of data, which might affect the swap times. for example, 0>2, 2>1, 1>0, 3->4, 4>5, 5>3, totally there are 4 swaps, but my first try uses another simple method which gets 5 swaps and that is wrong.