
思路比较见高低
路漫漫,远修兮
这个作者很懒,什么都没留下…
展开
-
LeetCode_26. 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 another array, you must do this ...原创 2019-03-24 18:46:18 · 196 阅读 · 0 评论 -
LeetCode_532. K-diff Pairs in an Array_路漫漫远修兮
一、原题目Given an array of integers and an integerk, you need to find the number ofuniquek-diff pairs in the array. Here ak-diffpair is defined as an integer pair (i, j), whereiandjare both nu...原创 2019-04-19 09:00:11 · 158 阅读 · 0 评论 -
LeetCode_557. Reverse Words in a String III_路漫漫远修兮
一、原题目Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.二、题目大意给定一个字符串s,要求反转字符串中的每一个单词三、思路...原创 2019-04-17 20:51:28 · 128 阅读 · 0 评论 -
LeetCode_217. Contains Duplicate_路漫漫远修兮
一、原题目Given an array of integers, find if the array contains any duplicates.Your function should return true if any value appears at least twice in the array, and it should return false if every...原创 2019-03-26 20:28:55 · 215 阅读 · 0 评论 -
LeetCode_219. Contains Duplicate II_路漫漫远修兮
一、原题目Given an array of integers and an integerk, find out whether there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and theabsolutedifference betweeniandjis a...原创 2019-03-26 20:57:22 · 155 阅读 · 0 评论 -
LeetCode_220. Contains Duplicate III_路漫漫远修兮
一、原题目Given an array of integers, find out whether there are two distinct indicesiandjin the array such that theabsolutedifference betweennums[i]andnums[j]is at mosttand theabsoluted...原创 2019-03-26 21:23:36 · 173 阅读 · 0 评论 -
LeetCod_128. Longest Consecutive Sequence_路漫漫远修兮
一、原题目Given an unsorted array of integers, find the length of the longest consecutive elements sequence.Your algorithm should run in O(n) complexity.二、题目大意给定一个含有数字的列表,求连续数的最大长度。三、思路分析...原创 2019-03-27 21:14:06 · 180 阅读 · 0 评论 -
LeetCode_334. Increasing Triplet Subsequence_路漫漫远修兮
一、原题目Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.Formally the function should:Return true if there existsi, j, ksuch thatarr[i]...原创 2019-03-26 20:04:42 · 130 阅读 · 0 评论 -
LeetCode_11. Container With Most Water_路漫漫远修兮
一、原题目Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of lineiis at (i,ai) and (i, 0)...原创 2019-03-25 21:58:28 · 131 阅读 · 0 评论 -
LeetCod_27Remove Element
一、原题目Given an arraynumsand a valueval, remove all instances of that valuein-placeand return the new length.Do not allocate extra space for another array, you must do this bymodifying the i...原创 2019-03-24 17:13:36 · 187 阅读 · 0 评论 -
LeetCode_921. Minimum Add to Make Parentheses Valid_路漫漫远修兮
一、原题目Given a stringSof'('and')'parentheses, we add the minimum number of parentheses ('('or')', and in any positions ) so that the resulting parentheses string is valid.Formally, a parenth...原创 2019-03-23 21:11:05 · 173 阅读 · 0 评论 -
LeetCode_406.Queue Reconstruction by Height_路漫漫远修兮
一、原题目Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers(h, k), wherehis the height of the person andkis the number of people in front o...原创 2019-03-23 20:13:56 · 130 阅读 · 0 评论 -
集合_字典_列表_enumerate()基本知识点总结
一、集合集合:是一个无序的不重复元素序列。1.添加元素:1.s.add( x ) (添加一个元素)2.s.update( x ) 参数可以是列表,元组,字典等,(添加多个元素)2.删除元素:s.remove( x ) x不存在出错s.discard( x ) x不存在不会出错3.数学中的集合运算:参考链接:https://www.jb5...原创 2019-03-30 17:16:35 · 801 阅读 · 0 评论 -
LeetCode_392.Is Subsequence_路漫漫远修兮
一、原题目Given a stringsand a stringt, check ifsis subsequence oft.You may assume that there is only lower case English letters in bothsandt.tis potentially a very long (length ~= 500,000) s...原创 2019-03-23 10:24:53 · 136 阅读 · 0 评论 -
LeetCode_455. Assign Cookies_路漫漫远修兮
一、原题目Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size o...原创 2019-03-22 21:53:22 · 157 阅读 · 0 评论 -
LeetCode_80. Remove Duplicates from Sorted Array II_路漫漫远修兮
一、原题目Given a sorted arraynums, remove the duplicatesin-placesuch that duplicates appeared at mosttwiceand return the new length.Do not allocate extra space for another array, you must do t...原创 2019-03-24 19:02:31 · 137 阅读 · 0 评论 -
LeetCode_101. Symmetric Tree_路漫漫远修兮
一、原题目Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).二、题目大意给定一个二叉树,判断是否为中心对称(镜像)三、思路分析别人的思路:主要思路还是分情况讨论,如果左右结点都为空,跳过当前循环;如果左右结点中只...原创 2019-04-23 21:46:10 · 154 阅读 · 0 评论