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.
New Year Chaos
New Year Chaos
Sort by
recency
|
1940 Discussions
|
Please Login in order to post a comment
Hi. I did not understand the input. Are there more than one array and we need to promediate? and the 3rd expected output is just 4. And what happend with the two caothic string? Thanks!
I've implemented a simple lookahead building upon @princealonte solution after noticing you only need contextual information from 3 adjacent values that you compare from the current index.
We just have to update the lookahead values depeding on three cases.
Here the corresponding c++ solution :
I've implemented BubbleSort algorithm in C#, to count the swaps.
OBS; this is not the best solution. O(n^2) time complexity.