![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
文章平均质量分 77
grow_to
修身齐家
展开
-
leetcode编程记录1 #8 String to Integer (atoi)
今天是第一次记录在leetcode上的做题的解题过程。 先看第一题:String to Integer (atoi)Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not s原创 2017-09-09 15:56:13 · 191 阅读 · 0 评论 -
leetcode编程记录11 #508 Most Frequent Subtree Sum
leetcode编程记录11 #508 Most Frequent Subtree Sum标签(空格分隔): leetcode这是一道有关树的数据结构的题目,巧妙地利用数据结构可以很快解决这个问题。题目如下: Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum原创 2017-11-04 22:07:25 · 124 阅读 · 0 评论 -
leetcode编程记录18 #59 Spiral Matrix II
leetcode编程记录18 #59 Spiral Matrix II标签(空格分隔): leetcode c++这道题是一道稍微有点复杂的题目,以前自己做的时候做了很久才做出来,现在加了一些数据结构进去,更简单地做了出来,题目如下:Given an integer n, generate a square matrix filled with elements from 1 to n2 in sp原创 2017-12-19 21:51:55 · 126 阅读 · 0 评论 -
leetcode编程记录19 #47 Permutations II
leetcode编程记录19 #47 Permutations II标签(空格分隔): leetcode c++这道题目是一道可以用递归的思想来解决的排列的问题,题目如下:Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,原创 2017-12-20 19:27:03 · 135 阅读 · 0 评论 -
leetcode编程记录14 #62 Unique Paths
leetcode编程记录14 #62 Unique Paths标签(空格分隔): leetcode这是一道很简单的动态规划的题目,题目如下:A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down原创 2017-11-24 14:06:11 · 151 阅读 · 0 评论 -
leetcode编程记录15 #442 Find All Duplicates in an Array
leetcode编程记录14 #442 Find All Duplicates in an Array标签(空格分隔): leetcode这次是一道比较简答的题目,但很有技巧性的一道题目,主要是要我们能够充分的利用题目的条件和所给的存储空间。题目如下:Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements原创 2017-12-03 12:16:29 · 152 阅读 · 0 评论 -
leetcode编程记录16 #31 Next Permutation
leetcode编程记录16 #31 Next Permutation标签(空格分隔): leetcode这次的题目是稍微有点难度的题目,是要我们对数字进行重排列的一道题目,题目如下:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of n原创 2017-12-06 19:41:07 · 149 阅读 · 0 评论 -
leetcode编程记录17 #42 Trapping Rain Water
leetcode编程记录17 #42 Trapping Rain Water标签(空格分隔): leetcode这是一道比较难的题目,主要是很难找到一种合理的算法来解决这个问题,我想了很多种方法,最后还是看了leetcode上的相关讨论才有了一个很好的方法解决它。 题目如下: Given n non-negative integers representing an elevation map原创 2017-12-17 15:49:38 · 132 阅读 · 0 评论 -
leetcode编程记录20 #74 Search a 2D Matrix
leetcode编程记录20 #74 Search a 2D Matrix标签(空格分隔): leetcode这次是一道比较简单的查询的题目,只要将搜索的2d矩阵转换成一个一维的数组进行搜索即可。 题目如下: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the原创 2017-12-26 19:42:41 · 142 阅读 · 0 评论 -
leetcode记录 3. Longest Substring Without Repeating Characters
这次主要是查缺补漏,题目的主要意思是寻找没有重复字符的最大字符串,我一时也想不出好的方法,所以就按照论坛里面的解答来做题。通过解答我了解了,大致的思路就是用一个哈希表来存放不同字符的最新索引,然后在每一次更新索引的同时更新最大值即可。具体代码如下:class Solution { public int lengthOfLongestSubstring(String s) { ...原创 2019-02-25 16:20:09 · 107 阅读 · 0 评论 -
leetcode编程记录13 #637 Average of Levels in Binary Tree
leetcode编程记录13 #637 Average of Levels in Binary Tree标签(空格分隔): leetcode这次的题目是有关树的简单问题,按要求输出树的每一层的数据就可以了。题目如下: Given a non-empty binary tree, return the average value of the nodes on each level in the f原创 2017-11-17 16:26:31 · 167 阅读 · 0 评论 -
leetcode编程记录12 #688 Knight Probability in Chessboard
leetcode编程记录12 #688 Knight Probability in Chessboard标签(空格分隔): leetcode这次的题目是一道有关于动态规划的题目,是一道比较难的题目,要才用一些特殊的方法才能解决,题目如下:On an NxN chessboard, a knight starts at the r-th row and c-th column and attempts原创 2017-11-12 00:54:13 · 820 阅读 · 0 评论 -
leetcode编程记录2 #53 Maximum Subarray
leetcode编程记录2 #53 Maximum Subarray标签(空格分隔): leetcode这次这道题是运用了分治思想的一道题,题目如下:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the原创 2017-09-16 21:03:11 · 161 阅读 · 0 评论 -
leetcode编程记录4 #6 ZigZag Conversion
leetcode编程记录4 #6 ZigZag Conversion标签(空格分隔): leetcode这次的题目是有关于字符串的输入问题,题目如下:The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this原创 2017-09-29 21:37:11 · 162 阅读 · 0 评论 -
leetcode编程记录5 #5 Longest Palindromic Substring
leetcode编程记录5 #5 Longest Palindromic Substring标签(空格分隔): leetcode这还是一道有关字符串的问题,主要是关于回文子字符串的问题,题目如下: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length原创 2017-09-29 21:38:03 · 166 阅读 · 0 评论 -
leetcode编程记录3 #169 Majority Element
leetcode编程记录3 #169 Majority Element标签(空格分隔): leetcode这次这道题是一道有着多种解法的题目,题目如下: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ tim原创 2017-09-21 16:47:16 · 187 阅读 · 0 评论 -
leetcode编程记录7 #508 Most Frequent Subtree Sum
leetcode编程记录7 #508 Most Frequent Subtree Sum标签(空格分隔): leetcode今天做的是一道关于树的题,如果利用一些数据结构可以很快和很巧妙地做出来,题目如下:Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of原创 2017-10-19 12:05:02 · 151 阅读 · 0 评论 -
leetcode编程记录9 #543 Diameter of Binary Tree
leetcode编程记录9 #543 Diameter of Binary Tree标签(空格分隔): leetcode这次是一道关于树的题目,这是一个比较简单的题目,找出在树中的一条最长的路径的长度。题目如下:Given a binary tree, you need to compute the length of the diameter of the tree. The diameter o原创 2017-10-27 22:49:43 · 133 阅读 · 0 评论 -
leetcode编程记录10 #2 Add Two Numbers
leetcode编程记录10 #2 Add Two Numbers标签(空格分隔): leetcode这是一道利用链表来完成相应的加法的一道题,主要是要求我们熟练掌握链表的相关知识,题目如下:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in原创 2017-10-28 00:53:07 · 153 阅读 · 0 评论 -
leetcode编程记录8 #107 Binary Tree Level Order Traversal II
leetcode编程记录8 #508 Most Frequent Subtree Sum标签(空格分隔): 日记这次是一道比较简单的题目,题目如下: Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the原创 2017-10-21 01:56:48 · 144 阅读 · 0 评论 -
leetcode编程记录6 #23 Merge k Sorted Lists
leetcode编程记录6 #23 Merge k Sorted Lists标签(空格分隔): leetcode这次是一道关于合并k个有序链表的题目,题目如下:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.题目理解与分析: 题目要求我们合并k个有序的原创 2017-10-12 13:30:27 · 186 阅读 · 0 评论 -
leetcode记录 25. Reverse Nodes in k-Group
这是一道链表的插入题,虽然题目简单,但我还是做了不长时间,方法很简单,就是以一个k为循环周期整个链表做一遍尾插法使这些节点逆序,然后再在最后的不满k个的尾部几个节点再做一遍尾插就能使尾部这几个节点恢复正常的顺序了。代码如下:/** * Definition for singly-linked list. * public class ListNode { * int val; *...原创 2019-02-25 20:31:56 · 105 阅读 · 0 评论