随笔分类 - 其他-算法
摘要:递归的精髓在于某一个方法具体是做什么的! 比如下面setChild(),查询节点所有的子节点。 public List<TreeNode> transDepartment(List<Qydy> rootList){ List<TreeNode> nodeList = new ArrayList<>(
阅读全文
摘要:-1 -1 -1 -1 1 1 -1 1 1 最大子矩阵和是 1 1 1 1 class Main{ public static void main(String[] args) throws Exception{ Scanner in = new Scanner(System.in); // in
阅读全文
摘要:雪花算法 一共64个比特 第一个部分,是 1 个 bit:0,这个是无意义的。 第二个部分是 41 个 bit:表示的是时间戳(最小毫秒级别)。 第三个部分是 5 个 bit:表示的是机房 id,10001。 第四个部分是 5 个 bit:表示的是机器 id,1 1001。 第五个部分是 12 个
阅读全文
摘要:多个线程对list操作,每个线程处理list中的每一段数据 比如,线程1处理0-100的数据,线程2处理100-200的数据 class A{ public static void main(String[] args){ List<String> scheList = new ArrayList<
阅读全文
摘要:1、首先建立0-232-1个数据围城一圈。 2、将服务器分散到里面 3、建立多个虚拟服务器分散到圆圈里面,虚拟服务器和真实服务器绑定,请求虚拟服务器,会转发到真实服务器中
阅读全文
摘要:最佳实现 public void main(){ String a = "sfsdf"; byte[] items = a.getBytes(); items[0] = (byte) ((char) items[0] - 'a' + 'A'); System.out.print(new String
阅读全文
摘要:二分查找算法 public class Demo { public static void main(String[] args){ int[] num = {1,2,3,4}; int index = 3; int start = 0; int end = num.length-1; boolea
阅读全文
摘要:插入排序算法 public class Demo { public static void main(String[] args){ int[] num = {6,4,6,3,2,1,4,2,67,8,34,9}; for(int i=0;i<num.length-1;i++){ int temp
阅读全文

浙公网安备 33010602011771号