Liutauras Vilda wrote:You have comment:
That comment is incorrect. There is a key and a value, not the two keys.
You have some magic number there, which is 25. You either supposed to have a descriptive variable what it represents, or explanation why is 25 there. For example: restricted length on db table's field.
Liutauras Vilda wrote:Now I'm playing silly, you might want to save it to database or something? Then change the method name if that's the case.
Liutauras Vilda wrote:
Saurabh Pillai wrote:
This signature doesn't make sense to me. Think why.
Campbell Ritchie wrote:Or, in non‑cowboy language, start throwing some Exceptions and get it over and done with. Who needs to do lots of processing when one already knows the result is going to be invalid?
Carey Brown wrote:I wouldn't use a sort(). A HashMap with count for a value would be quicker.
Saurabh Pillai wrote:
Time complexity of getDuplicates method:
Let's assume that list has N elements.
- Collections.sort(input), O(N LogN)
- duplicates.add(a);, for HashSet add is constant O(1)
O(N LogN) + O(1)
= O(N LogN)