Reputation: 209
I have the following algorithm, can somebody help me solve this? I just need an explanation.
"A vector a[] with n integer elements is cube-repetition-free if no element is the cube of another element, i.e., there are no indices i,j such that a[i] = a[j]3 . Propose an O(n*log(n))-time algorithm in order to decide whether a vector is cube-repetition-free."
Upvotes: 0
Views: 85
Reputation: 8763
O(n) solution:
O(n*logn) solution:
Upvotes: 2