package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/search-for-a-range/
 */
public class Problem34 {
    public int[] searchRange(int[] nums, int target) {
        return null;
    }
    
    public static void main(String[] args) {
        Problem34 prob = new Problem34();
        System.out.println(Arrays.toString(prob.searchRange(new int[]{5, 7, 7, 8, 8, 10}, 8))); // [3, 4]
    }
}

@@ -16,34 +16,8 @@
 e;%0A%0A
-import java.util.Arrays;%0A%0A
 /**%0A
@@ -165,73 +165,280 @@
     
-return null;%0A    %7D%0A    %0A    public static void main(String%5B%5D args
+int lo = 0;%0A        int hi = nums.length - 1;%0A        int%5B%5D result = new int%5B2%5D;%0A        while (lo %3C= hi) %7B%0A            int mid = (lo + hi) / 2;%0A            if (nums%5Bmid%5D == target) %7B%0A                int left = mid;%0A                while (left %3E= 0 && nums%5Bleft%5D == target
 ) %7B%0A
@@ -449,147 +449,849 @@
     
-Problem34 prob = new Problem34();%0A        System.out.println(Arrays.toString(prob.searchRange(new int%5B%5D%7B5, 7, 7, 8, 8, 10%7D, 8))); // %5B3, 4%5D
+            left--;%0A                %7D%0A                if (left == 0 && nums%5Bleft%5D == target) %7B%0A                    result%5B0%5D = left;%0A                %7D else %7B%0A                    result%5B0%5D = left + 1;%0A                %7D%0A                int right = mid;%0A                while (right %3C= nums.length-1 && nums%5Bright%5D == target) %7B%0A                    right++;%0A                %7D%0A                if (right == nums.length-1 && nums%5Bright%5D == target) %7B%0A                    result%5B1%5D = right;%0A                %7D else %7B%0A                    result%5B1%5D = right - 1;%0A                %7D%0A                return result;%0A            %7D else if (nums%5Bmid%5D %3C target) %7B%0A                lo = mid + 1;%0A            %7D else %7B // nums%5Bmid%5D %3E target%0A                hi = mid - 1;%0A            %7D%0A        %7D%0A        result%5B0%5D = -1;%0A        result%5B1%5D = -1;%0A        return result;
 %0A   

Solve problem 34