O(nlogn) ??

1 vote

What is the worst case time complexity to count pairs of numbers with difference ‘*k*’ from an input array of ‘*n*’ numbers?

a) O(logn)

b) O(nlogn)

c) O(n^2)

d) O(n^2logn)

0

@ Ashwin Kulkarni As worst case complexity is asked shouldn't we just iterate outer loop from 0 to 'n-1' and the inner loop from i+1 to n? What was your algo behind nlogn?