摘要:
写一个函数,求两个整数之和,要求在函数体内不得使用+、-、*、/四则运算符号。 分析:只能用 与或 运算符 public class Solution { public int Add(int num1,int num2) { while( num2!=0 ){ int sum = num1 ^ n 阅读全文
摘要:
题目描述 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。 public int Sum_Solution(int n) { int sum = n; (sum!=0) && ((sum += Sum_So 阅读全文
摘要:
题目描述 给定一棵二叉搜索树,请找出其中的第k小的结点。例如, (5,3,7,2,4,6,8)中,按结点数值大小顺序第三小结点的值为4。 解题思路 因为中序遍历有序,所以直接对这颗树进行中序遍历就好,当遍历到第k个点时候,即为所求点 参考代码 /* public class TreeNode { i 阅读全文
摘要:
D. Anton and Chess time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output D. Anton and Chess ti 阅读全文
摘要:
C. Anya and Smartphone time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output C. Anya and Smartp 阅读全文
摘要:
B. Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output B. Mike and Feet time li 阅读全文
摘要:
B. Han Solo and Lazer Gun time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output B. Han Solo and 阅读全文