Maximum Expression Value I 给定一个整数数组,要求在数字之间任意添加乘号,加号和括号,使得最后表达式结果最大。比如1121,最大值为(1+1)*(2+1),所有数字都是正数。 动态规划 复杂度 …
分类:LeetCode
【leetcode】69. Sqrt(x) 整数开方计算最合适的小的数
1. 题目 Implement int sqrt(int x). Compute and return the square root of x. 注:对于5,6,7,8等都返回2. 2. 思路 用牛顿开方法计算。原理:…
LeetCode-67. Add Binary
问题描述 Given two binary strings, return their sum (also a binary string). For example, a = “11” b = …
[剑指offer] 按之字形顺序打印二叉树
本文首发于我的个人博客:尾尾部落 题目描述 请实现一个函数按照之字形打印二叉树,即第一行按照从左到右的顺序打印,第二层按照从右至左的顺序打印,第三行按照从左到右的顺序打印,其他行以此类推。 解题思路 设两个栈,s2存放奇…
[LeetCode]Merge Sorted Array 合并排序数组
链接:https://leetcode.com/problems/merge-sorted-array/description/ 难度:Easy 题目:88. Merge Sorted Array Given two s…
[LeetCode] Word Search II 词语搜索之二,Word Search 词语搜索,Add and Search Word - Data structure design 添加和查找单词-数据结构设计,Word Search 词语搜索
Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must b…
[LeetCode] Alien Dictionary 另类字典
There is a new alien language which uses the latin alphabet. However, the order among letters are unkno…
[LeetCode] Path Sum III 二叉树的路径和之三
You are given a binary tree in which each node contains an integer value. Find the number of paths that…
[LeetCode] Binary Tree Longest Consecutive Sequence II 二叉树最长连续序列之二
Given a binary tree, you need to find the length of Longest Consecutive Path in Binary Tree. Especially…
LeetCode 080 Remove Duplicates from Sorted Array II
题目描述 Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice? For example, Given sorte…
[Lintcode] Find Peak Element 找峰值
Find Peak Element I A peak element is an element that is greater than its neighbors. Given an input array wher…
【leetcode】35. Search Insert Position 给定数字插入有序数组的下标点
1. 题目 Given a sorted array and a target value, return the index if the target is found. If not, return the ind…