摘要:
已有方法 rand7 可生成 1 到 7 范围内的均匀随机整数,试写一个方法 rand10 生成 1 到 10 范围内的均匀随机整数。 public class Solution { public static int rand10() { int ans = rand2(); for (int i 阅读全文
摘要:
1、 饿汉模式 线程安全 public class SingleInstance1 { private static SingleInstance1 single=new SingleInstance1(); private SingleInstance1(){ } public static Si 阅读全文
摘要:
解法一:从上到下计算(后序遍历) class Solution { public int maxDepth(TreeNode root) { if (root == null) { return 0; } int left = maxDepth(root.left); int right = max 阅读全文