class Solution {
public int findRepeatNumber(int[] nums){
int i =0;
while(i < nums.length){
if(nums[i]== i){
i++;continue;}
if(nums[nums[i]]== nums[i])return nums[i];
int tmp = nums[i];
nums[i]= nums[tmp];
nums[tmp]= tmp;}return -1;}}
class Solution {
public int search(int[] nums, int target){
if(nums.length ==0){return0;}
int left = binarySearch(nums,target,true);
int right = binarySearch(nums,target,false);
if(left == right){return0;}return right - left;}
public int binarySearch(int [] arr,int target, boolean lower){
int left =0;
int right = arr.length -1;
int ans = arr.length;
while(left <= right){
int mid =(left + right)/2;
if(arr[mid]> target ||(lower && arr[mid]== target)){
right = mid -1;
ans = mid;}else {
left = mid + 1;}}return ans;}}
class Solution {
public int missingNumber(int[] nums){
int i =0, j = nums.length - 1;
while(i <= j){
int m =(i + j) / 2;
if(nums[m]== m) i = m + 1;else j = m - 1;}return i;}}