摘要:
1. 某个数是否存在于二维数组中 1 public boolean search(int[][] m, int target) { 2 if (m.length == 0 || m[0].length == 0) { 3 return false; 4 } 5 int l = 0; 6 int r 阅读全文
摘要:
普通二分查找 public static int search(int[] arr, int target) { int l = 0; int r = arr.length; while (l < r) { int mid = l + ((r - l) >> 1); if (arr[mid] < t 阅读全文
摘要:
1. 不用比较判断找出AB中较大的数 1 public class getMaxWithOutCompair { 2 public int flip(int n) { 3 return n ^ 1; 4 } 5 6 public int sign(int n) { 7 // 如果负数返回0 如果正数 阅读全文
摘要:
1 public class Element<V> { 2 public V value; 3 4 public Element(V value) { 5 this.value = value; 6 } 7 8 public static class UnionFindSet<V> { 9 publ 阅读全文