摘要: 前序: 1 class Solution: 2 def preorderTraversal(self, root: TreeNode) -> List[int]: 3 res=[] 4 stack=[] 5 while root or stack: 6 if root: 7 stack.append 阅读全文
posted @ 2019-12-27 21:58 Assange 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 题目描述 将一个字符串转换成一个整数,要求不能使用字符串转换整数的库函数。 数值为0或者字符串不是一个合法的数值则返回0 输入描述: 输入一个字符串,包括数字字母符号,可以为空 输出描述: 如果是合法的数值表达则返回该数字,否则返回0 1 # -*- coding:utf-8 -*- 2 class 阅读全文
posted @ 2019-12-27 19:39 Assange 阅读(284) 评论(0) 推荐(0) 编辑
摘要: 题目描述 写一个函数,求两个整数之和,要求在函数体内不得使用+、-、*、/四则运算符号。 java public class Solution { public int Add(int num1,int num2) { while (num2!=0) { int temp = num1^num2; 阅读全文
posted @ 2019-12-27 19:07 Assange 阅读(311) 评论(0) 推荐(0) 编辑
摘要: 题目描述 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。 1 # -*- coding:utf-8 -*- 2 class Solution: 3 def Sum_Solution(self, n): 4 阅读全文
posted @ 2019-12-27 17:02 Assange 阅读(219) 评论(0) 推荐(0) 编辑