
leetcode
文章平均质量分 62
TianXieErYang
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【力扣】两个链表的第一个公共节点:优雅的双指针
题目输入两个链表,找出它们的第一个公共节点。如下面的两个链表:在节点 c1 开始相交。分析思路和算法使用双指针的方法,可以将空间复杂度降至 O(1)O(1)。若headA 和 headB其中之一为空,则不相交,返回None;若均不为空,设两个新指针pA,pB分别指向 headA和headB,同时移动pA,pB。若pA/pB不为空,均移动到各自的下一个节点,否则pA指向headB,pB指向headA,直到pA 和pB指向同一个节点。论证求headA 的长度为m, h原创 2021-07-21 22:53:33 · 304 阅读 · 2 评论 -
【leetcode】11. Container With Most Water
11. Container With Most WaterProblemSolution1、C 8 ms, faster than 65.90% 8 MB, less than 44.59%ProblemGiven n non-negative integers a1, a2, …, an , where each represents a point at coordi...原创 2019-02-26 15:08:41 · 207 阅读 · 0 评论 -
【leetcode】28. Implement strStr()
28. Implement strStrProblemSolution1、C (一般解法)2、 C (KMP)ProblemImplement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example...原创 2019-03-02 11:48:50 · 268 阅读 · 0 评论 -
【leetcode】25. Reverse Nodes in k-Group
25. Reverse Nodes in k-GroupProblemSolution1、Python 递归 (36 ms, faster than 99.50%)ProblemGiven a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a p...原创 2019-01-23 17:55:01 · 146 阅读 · 0 评论 -
【leetcode】23. Merge k Sorted Lists
23. Merge k Sorted ListsProblemSolution1、Python (124 ms, faster than 61.75% )ProblemMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:...原创 2019-01-17 20:26:22 · 133 阅读 · 0 评论 -
【leetcode】14. Longest Common Prefix
14. Longest Common PrefixProblemsolutionProblemWrite a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string “”.Example...原创 2018-12-19 19:57:36 · 143 阅读 · 0 评论 -
【leetcode】13. Roman to Integer
13. Roman to IntegerProblemSolutionProblemRoman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L ...原创 2018-12-19 20:04:31 · 153 阅读 · 0 评论 -
【leetcode】15. 3Sum
15. 3SumProblemSolution1. pythonProblemGiven 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 zer...原创 2018-12-24 20:37:35 · 136 阅读 · 0 评论 -
【leetcode】18. 4Sum
18. 4SumProblemSolution (1240 ms)ProblemGiven an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruple...原创 2018-12-27 19:16:24 · 131 阅读 · 0 评论 -
【leetcode】4. Median of Two Sorted Arrays
4. Median of Two Sorted ArraysProblemSolution1、python (108ms)ProblemThere are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall ru...原创 2019-01-04 10:43:51 · 134 阅读 · 0 评论 -
【leetcode】88. Merge Sorted Array
88. Merge Sorted ArrayProblemSolution1、Python (36 ms)2、CProblemGiven two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized i...原创 2019-01-15 19:59:57 · 124 阅读 · 0 评论 -
【leetcode】21. Merge Two Sorted Lists
21. Merge Two Sorted ListsProblemSolution1、python (72ms)ProblemMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two ...原创 2019-01-08 20:16:07 · 159 阅读 · 0 评论 -
【leetcode】148. Sort List
148. Sort ListProblemSolution1、Python (320 ms , faster than 68.55%)ProblemSort a linked list in O(n log n) time using constant space complexity.Example 1:Input: 4->2->1->3Output: 1->2...原创 2019-01-17 17:16:53 · 254 阅读 · 0 评论