Skip to content

Instantly share code, notes, and snippets.

View virengujariya's full-sized avatar

Viren Gujariya virengujariya

View GitHub Profile
@virengujariya
virengujariya / duplicate.md
Last active July 9, 2018 17:52
Data structure and algorithms

Given array of positive items = {1, 2, 3, 4, 4} the simplest brute force solution could be as per below. However, this solution has Time complexity O(n^2)

Do you think there is better solution? Let's find out.

public class Test {
    public static int find(int[] items) {
        int length = items.length;
 for (int i = 0; i < length; i++) {