![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
文章平均质量分 72
yesr2014
大连理工大学软件工程专业本科生
展开
-
94. Binary Tree Inorder Traversal
【思路分析】二叉树中序遍历的实现通常有两种方法:递归和迭代。递归思路很简单,所以这里我只说迭代版本的思路。根据中序遍历的顺序,对于任一结点,优先访问其左孩子,而左孩子结点又可以看做一根结点,然后继续访问其左孩子结点,直到遇到左孩子结点为空的结点才进行访问,然后按照相同的规则访问其 右子树。因此处理过程如下:对任一结点p1.若其左孩子不为空,则将p入栈并将p的左孩子置为当前的p,然后...原创 2020-05-01 03:01:20 · 303 阅读 · 0 评论 -
238. Product of Array Except Self
Product of Array Except Self【题目】Given an arraynumsofnintegers wheren> 1, return an arrayoutputsuch thatoutput[i]is equal to the product of all the elements ofnumsexceptnums[i].Ex...原创 2019-04-02 17:21:11 · 376 阅读 · 0 评论 -
26. Remove Duplicates from Sorted Array
Remove Duplicates from Sorted Array【题目】Given a sorted arraynums, remove the duplicatesin-placesuch that each element appear onlyonceand return the new length.Do not allocate extra space for...原创 2019-03-15 20:29:31 · 210 阅读 · 0 评论 -
15. Three Sum
Three Sum【题目】Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.(给定一个包含 n 个整数的数组 num...原创 2018-11-20 00:56:40 · 236 阅读 · 0 评论 -
167. Two Sum II - Input array is sorted(双向指针)
Two Sum II - Input array is sorted【题目】Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum...原创 2018-11-08 20:01:43 · 152 阅读 · 0 评论 -
1. Two Sum(HashMap储存数组的值和索引)
Two Sum【题目】Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may no...原创 2018-11-08 19:46:19 · 318 阅读 · 0 评论 -
35. Search Insert Position(二分法)
Search Insert Position【题目】Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume...原创 2018-11-07 23:10:33 · 133 阅读 · 0 评论 -
7. Reverse Integer(注意越界问题)
Reverse Integer【题目】Given a 32-bit signed integer, reverse digits of an integer.(翻译:给定一个 32 位有符号整数,将整数中的数字进行反转。)Example:Input: 123Output: 321Input: -123Output: -321Input: 120Output: 2...原创 2018-11-07 15:23:17 · 325 阅读 · 0 评论 -
189. Rotate Array(三步旋转法)
Rotate Array【题目】Given an array, rotate the array to the right by k steps, where k is non-negative.(翻译:给定一个数组,将数组中的元素向右移动 k 个位置,其中 k 是非负数。)Example 1:Input: [1,2,3,4,5,6,7] and k = 3Output: ...原创 2018-11-04 21:15:12 · 271 阅读 · 0 评论 -
3. Longest Substring Without Repeating Characters(HashSet + 双指针)
Longest Substring Without Repeating Characters【题目】Given a string, find the length of the longest substring without repeating characters.(给定一个字符串,找字符中的最大非重复子串)Example 1:Input: "abcabcbb"Out...原创 2018-11-09 15:22:47 · 180 阅读 · 0 评论 -
121. Best Time to Buy and Sell Stock
Best Time to Buy and Sell Stock【题目】Say you have an array for which the i th element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., b...原创 2018-11-09 14:43:13 · 157 阅读 · 0 评论 -
119. Pascal's Triangle II(杨辉三角简单变形)
Pascal's Triangle II【题目】Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle.Note that the row index starts from 0.(翻译:给定一个非负索引 k,其中 k ≤ 33,返回杨辉三角的第 k 行...原创 2018-11-04 00:40:03 · 272 阅读 · 0 评论 -
118. Pascal's Triangle(暴力求解法)
Pascal's Triangle【题目】Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.(翻译:给定一个非负整数 numRows,生成杨辉三角的前 numRows 行。)In Pascal's triangle, each number is the s...原创 2018-11-04 00:26:18 · 185 阅读 · 0 评论 -
53. Maximum Subarray (Kadane算法 / 动态规划 / 分治法)
Maximum Subarray【题目】Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5...原创 2018-11-02 22:11:27 · 431 阅读 · 0 评论