摘要: 1 public int findDuplicate(int[] nums) { 2 Arrays.sort(nums); 3 for (int i = 0; i < nums.length - 1; i++) { 4 if (nums[i] == nums[i + 1]) { 5 return n 阅读全文
posted @ 2020-12-03 20:37 加利亚的赤色恶魔 阅读(97) 评论(0) 推荐(0)
摘要: 1 class Solution { 2 public int countPrimes(int n) { 3 int count = 0; 4 for(int i = 2; i < n; i++){ 5 if(isPrime(i)) count++; 6 } 7 return count; 8 } 阅读全文
posted @ 2020-12-03 11:29 加利亚的赤色恶魔 阅读(147) 评论(0) 推荐(0)
摘要: 1 int binarySearch(int[] nums, int target) { 2 int left = 0, right = ...; 3 4 while(...) { 5 int mid = (right + left) / 2; 6 if (nums[mid] == target) 阅读全文
posted @ 2020-12-02 20:37 加利亚的赤色恶魔 阅读(94) 评论(0) 推荐(0)
摘要: 1 class Solution { 2 public int[] searchRange(int[] nums, int target) { 3 int[] res = {-1 , -1}; 4 int len = nums.length; 5 for(int i = 0; i < len; i+ 阅读全文
posted @ 2020-12-01 20:42 加利亚的赤色恶魔 阅读(61) 评论(0) 推荐(0)