[LeetCode]109. Convert Sorted List to Binary Search Tree 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 题目地址:https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/description/ 题目描述: Given a s…
66 - Plus One Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. Solution 1 : 十进制加法 class Solution { public: vector<int> plusO…
Different Ways to Add Parentheses Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are+, - and *. Example 1 Input: "2-1-1". ((…
66. 加一 知识点:数组: 题目描述 给定一个由 整数 组成的 非空 数组所表示的非负整数,在该数的基础上加一. 最高位数字存放在数组的首位, 数组中每个元素只存储单个数字. 你可以假设除了整数 0 之外,这个整数不会以零开头. 示例 输入:digits = [1,2,3] 输出:[1,2,4] 解释:输入数组表示数字 123. 输入:digits = [4,3,2,1] 输出:[4,3,2,2] 解释:输入数组表示数字 4321. 输入:digits = [0] 输出:[1] 解法一: 这个…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 数九 采用进位 日期 [LeetCode] 题目地址:https://leetcode.com/problems/plus-one/ Total Accepted: 99274 Total Submissions: 294302 Difficulty: Easy 题目描述 Given a non-empty array of digits repre…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:递归构建所有表达式 方法二:分而治之 日期 题目地址:https://leetcode.com/problems/different-ways-to-add-parentheses/description/ 题目描述 Given a string of numbers and operators, return all possible re…
题目: Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. 提示: 此题其实是模拟我们在小学时候学习的加法进位的操作.难度不大. 代码: 空间复杂度是O(n)的方法: class Solution { p…
Plus One Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. 从个位数字往前扫,只要一个数字不产生进位,即可加1返回. 如果直到最高位仍有进位,则在数组头部插入1,结果为100…0 解法一: in…
package y2019.Algorithm.str.hard; import java.util.Stack; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.str.hard * @ClassName: LongestValidParentheses * @Author: xiaof * @Description: 32. Longest Valid Parentheses * * Given a string co…
原题 Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: Input: 3 / 9 20 / 15 7 Output: [3, 14.5, 11] Explanation: The average value of nodes on level 0 is 3, on level 1 is 14.5, and on…