摘要:
N-ary Tree Preorder Traversal N叉树前序遍历 给一个N叉树的root,返回其前序遍历 输入:root = [1,null,3,2,4,null,5,6] 输出:[1,3,5,6,2,4] /* // Definition for a Node. class Node { 阅读全文
摘要:
Binary Tree Preorder Traversal二叉树的前序遍历 给一个root,返回前序遍历 前序遍历: 根->左->右 递归方法 public void preorder(TreeNode root,List<Integer> res){ if(root == null){ retu 阅读全文
摘要:
Longest Well-Performing Interval 表现良好的最长时间段 We are given hours, a list of the number of hours worked per day for a given employee. A day is considered 阅读全文
摘要:
Exclusive Time of Functions 函数占用时间 在单核单线程CPU上执行任务,任务id 从0到n-1,任务会交替间断执行, Input: n = 2, logs = ["0:start:0","1:start:2","1:end:5","0:end:6"] Output: [3 阅读全文
摘要:
Basic Calculator II 基本计算器 给定一个字符串格式的算式,计算该式的值。只包含+-*/ Input: s = "3+2*2" Output: 7 Input: s = " 3+5 / 2 " Output: 5 思路 使用2个栈,nums存放数字,op存放符号; public i 阅读全文
摘要:
Verify Preorder Serialization of a Binary Tree 验证二叉树前序序列化 前序遍历是啥就不说了,百度一下, 简单说就是root-> left_child->right_child.被前序序列化的二叉树就是一个按照前序遍历的顺序,空节点用#来标识。 该二叉树可 阅读全文
摘要:
Binary Tree Postorder Traversal 二叉树后序遍历 后序遍历是啥就不说了,百度一下, 简单说就是 left_child->right_child->root. Input: root = [1,null,2,3] Output: [3,2,1] 思路 递归处理 /** * 阅读全文
摘要:
Minimum Remove to Make Valid Parentheses 移除无效的括号 给出一个string,其中包含(, ),以及小写字母a~z组成,要求删掉最少的(或),使得剩余的字符串是有效的括号字符串。 Input: s = "a)b(c)d" Output: "ab(c)d" I 阅读全文
摘要:
Remove Outermost Parentheses 删除最外层的括号 Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string i 阅读全文
摘要:
Valid Parentheses 有效的括号 Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. 左括号必须 阅读全文