Комментарии:
I'm just now learning about data structures and algorithms in C++. Correct me if I'm wrong, but I think this approach has a time complexity of O(n^2) because of the nested for loops, which is not that good if the arrays are really large. Is there a better/more efficient way to find duplicates in an array in Java?
ОтветитьI hope you are not a Senior. Because after first interview you will be in a black list😂 P.S. O(n^2) is a awful. You can use Hashset or sort array and find repeatable number
ОтветитьIt will fail for some edge cases
Ответитьor you can use list
arr.stream().filter(x -> x == 1).toList();
Bc 🔥🔥
ОтветитьWe can simply use stream for this
Ответитьwhy not just use "for each " element?..
Ответитьit doesnt work for 10000 elements arra
ОтветитьGood
ОтветитьData structure sikh pehle
Ответитьit wont work if i enter the input like int[] a = {1,4,3,1,4,4};
Ответить