摘要:
Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive intege 阅读全文
摘要:
循环求解方式不再赘述。 O(1)时间的方法: 公式:(num-1)%9 + 1; 假设num为一个五位数,num = (a + b + c + d + e) + (a * 9999 + b * 999 + c * 99 + d * 9),将num对9取余后,结果为a + b + c + d + e。 阅读全文
摘要:
public class TreeNode { TreeNode right; TreeNode left; int val;} import java.util.Stack;public class PreOrder { /* * 递归 */ public void preorder(TreeNo 阅读全文