Hi There is a difference between Arrays.sort and Bubble sort. When you use two for loops that means you are using bubble sort which gives time Complexity as big O( n^2) while when you use Arrays.sort it internally use quick sort for primitives and merge sort for objects which give average time complexity as big O(n) which is very optimized as compared to bubble sort. This is the reason why client was rejecting many candidates as time complexity wasn't good enough.
So what you can do to solve this problem is simply(either you set or simply write a for loop and iterate all the elements) remove duplicacy from array after that perform sorting.
Why voice quality of almost all videos are very low?
Hi There is a difference between Arrays.sort and Bubble sort. When you use two for loops that means you are using bubble sort which gives time Complexity as big O( n^2) while when you use Arrays.sort it internally use quick sort for primitives and merge sort for objects which give average time complexity as big O(n) which is very optimized as compared to bubble sort. This is the reason why client was rejecting many candidates as time complexity wasn't good enough.
So what you can do to solve this problem is simply(either you set or simply write a for loop and iterate all the elements) remove duplicacy from array after that perform sorting.
bhai want more of these please, i'm about to go through the client interview process
Sure Shubham.
Use Java 8 stream
Client wants plain Java code.
Good.