Timeline for Rearranging Cartons Algorithm
Current License: CC BY-SA 3.0
4 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 26, 2012 at 19:30 | comment | added | 7Aces | @KarlBielefeldt Thanks for the tip! Still, incorrect algorithm. Gives incorrect output for the test case - O={1,2,3,4,5,6} R={6,5,4,3,2,1}. Output - 9 (Should be 15) | |
Dec 26, 2012 at 16:13 | comment | added | Karl Bielefeldt |
@7Aces, oldindex(c) is an O(1) operation if you store it in a hash table.
|
|
Dec 26, 2012 at 15:30 | comment | added | 7Aces | An algorithm with a O(n^2) time complexity is just not efficient enough to solve the data ranges in the time limit. The most efficient algorithm for this possesses O(n log n) time, see - stackoverflow.com/questions/7797540/…. The algorithm provided resorts to O(n^2) complexity as it finds oldindex(c) with every iteration. | |
Dec 26, 2012 at 14:00 | history | answered | ratchet freak | CC BY-SA 3.0 |