2019年8月22日
摘要: 题目描述 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。 来源牛客。 1 public int Sum_Solution(int n) { 2 return sum(n); 3 //return (int 阅读全文
posted @ 2019-08-22 22:09 大猫食小鱼 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 题目描述 操作给定的二叉树,将其变换为源二叉树的镜像。 输入描述: 二叉树的镜像定义:源二叉树 8 / \ 6 10 / \ / \ 5 7 9 11 镜像二叉树 8 / \ 10 6 / \ / \ 11 9 7 5来源牛客。 1 public void Mirror(TreeNode root) 阅读全文
posted @ 2019-08-22 20:48 大猫食小鱼 阅读(285) 评论(0) 推荐(0) 编辑
摘要: 题目描述 写一个函数,求两个整数之和,要求在函数体内不得使用+、-、*、/四则运算符号。 来源牛客。 1 public int Add(int num1,int num2) { 2 //调用函数,当然函数底层肯定用了运算符号! 3 //return Integer.sum(num1,num2); 4 阅读全文
posted @ 2019-08-22 20:13 大猫食小鱼 阅读(636) 评论(0) 推荐(0) 编辑
摘要: 题目描述 输入一棵二叉树,求该树的深度。 从根结点到叶结点依次经过的结点(含根、叶结点)形成树的一条路径,最长路径的长度为树的深度。 来自牛客。 1 public int TreeDepth(TreeNode root) { 2 //递归实现 3 /*if(root == null){ 4 retu 阅读全文
posted @ 2019-08-22 17:25 大猫食小鱼 阅读(655) 评论(0) 推荐(0) 编辑