LeetCode题解之Climbing Stairs
1、题目描述2、问题分析使用动态规划。3、代码 int climbStairs(int n) { if( n <= ){ return n; } int dp[n+]; dp[] = ; d...
leetcode & lintcode 题解
刷题备忘录,for bug-free招行面试题--求无序数组最长连续序列的长度,这里连续指的是值连续--间隔为1,并不是数值的位置连续问题:给出一个未排序的整数数组,找出最长的连续元素序列的长度。如:给出[100, 4, 200, 1, 3, 2],最长的连续元素序列是[1, 2, 3, 4]。返回...
leetcode题解 5. Longest Palindromic Substring
题目:Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example:Input: "babad"Output: "b...
leetcode个人题解——#18 4sums
在3sums的基础上加了一层循环。class Solution {public: vector<vector<int>> fourSum(vector<int>& nums, int target) { sort(nums.begin(...
[LeetCode]题解(python):124-Binary Tree Maximum Path Sum
题目来源:https://leetcode.com/problems/binary-tree-maximum-path-sum/题意分析:给定一棵树,找出一个数值最大的路径,起点可以是任意节点或者叶子。题目思路:我们可以先找路径的最大mr,ml,那么最大值是max(solve(root),solve...
[LeetCode]题解(python):050-Pow(x, n)
题目来源https://leetcode.com/problems/powx-n/Implement pow(x, n).题意分析Input: x,nOutput:pow(x,n)Conditions:满足一定的内存需求,算法复杂度低一些题目思路刚开始以为直接乘就好了,但是爆内存了,仔细看发现其实可...
LeetCode题解(13)--Roman to Integer
https://leetcode.com/problems/roman-to-integer/原题:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to...
《LeetBook》leetcode题解(13):Roman to Integer[E]
我现在在做一个叫《leetbook》的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看 书的地址:https://hk029.gitbooks.io/leetbook/013. Roman to Integer问题Given a rom...
C#版 - Leetcode 593. 有效的正方形 - 题解
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm。C#版 - Leetcode 593. 有效的正方形 - 题解Leetcode 593. Valid Square在...
C#版 - Leetcode 633. 平方数之和 - 题解
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm。C#版 - Leetcode 633. 平方数之和 - 题解Leetcode 633 - Sum of square...
C#版 - Leetcode 414. Third Maximum Number题解
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm。C#版 - Leetcode 414. Third Maximum Number题解在线提交: https://le...
[LeetCode]题解(python):055-Jump Game
题目来源https://leetcode.com/problems/jump-game/Given an array of non-negative integers, you are initially positioned at the first index of the array.Each...
[LeetCode]题解(python):064-Minimum Path Sum
题目来源https://leetcode.com/problems/minimum-path-sum/Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right whic...
leetCode题解之求二叉树每层的平均值
1、题目描述Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array.计算二叉树每一层的节点的数据域的平均值。2、题目分析使用广度优先遍历方法,...
leetCode题解之Contains Duplicate
1、题目描述2、题目分析直接使用hashTable 计数,超过1 则返回true,最后返回 false即可。3、代码 bool containsDuplicate(vector<int>& nums) { if( nums.size() == ) ...
LeetCode题解-----Majority Element II 摩尔投票法
题目描述:Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) spac...
LeetCode题解之Contains Duplicate II
1、题目描述2、题目分析使用哈希表 和分情况讨论的方法3、代码bool containsNearbyDuplicate(vector<int>& nums, int k) { if( nums.size() == ){ return fals...
[LeetCode]题解(python):101 Symmetric tree
题目来源https://leetcode.com/problems/symmetric-tree/Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).题意分析Inp...
LeetCode题解33.Search in Rotated Sorted Array
33. Search in Rotated Sorted ArraySuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 m...
[LeetCode]题解(python):026-Remove Duplicates from Sorted Array
题目来源:https://leetcode.com/problems/remove-duplicates-from-sorted-array/题意分析:给定一个排好序的数组,去除重复的数,返回新数组的长度,不能申请额外的空间,超过新数组长度部分是什么数都无所谓。题目思路:这是一个很简单的题目,由于给...