Here, 'k' can be any integer.
My O(nlogn) solution is as follows :- https://ideone.com/Ff3CcO
Is there any O(n) algorithm for above?
Thanks.
Note:- 1)I've done my research. 2)No, this problem does not belong to any ongoing contest in the world :-)
Here, 'k' can be any integer.
My O(nlogn) solution is as follows :- https://ideone.com/Ff3CcO
Is there any O(n) algorithm for above?
Thanks.
Note:- 1)I've done my research. 2)No, this problem does not belong to any ongoing contest in the world :-)