Leetcode record - March 2023
Binary Search Find left bound/right bound public int[] searchRange(int[] nums, int target) { return new int[]{helper(nums, target, true), helper(nums, target, false)}; } public int helper(int[] nums, int target,boolean trueIfSearchLeftBound){ int l = 0; int r = nums.length-1; int res = -1; while (l<=r){ int midl = (l+r)/2; if (nums[midl]>target){ r = midl-1; }else if(nums[midl]<target){ l = midl+1; }else{ res = midl; if (trueIfSearchLeftBound){ r = midl-1; }else{ l = midl+1; } } } System....