Programming Competition and Programming Interview questions. And maybe some web stuff, too.
My submitted solution was wrong, but here's the correct (hopefully) solution I came up with after my submission.
Problem: Facebook Hacker Cup 2013 Qualification Round: (45) Find the Min
Solution: Time complexity - O(k) O(k^2)
my version in C:http://nopaste.me/paste/1190818255107a72e3b1b9execution time : 0.02s
How is it O(k) ?the for loop at line 34 has O(k) complexity and the while loop (line 37) inside this for loop has O(k) complexity. So, it has O(k^2) time complexity.
My bad, I really meant k^2.
my version in C:
ReplyDeletehttp://nopaste.me/paste/1190818255107a72e3b1b9
execution time : 0.02s
How is it O(k) ?
ReplyDeletethe for loop at line 34 has O(k) complexity and the while loop (line 37) inside this for loop has O(k) complexity. So, it has O(k^2) time complexity.
My bad, I really meant k^2.
Delete