随笔分类 -  leetcode

摘要:题目描述 Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given[100, 4, 200, 1, 3, 2], The 阅读全文
posted @ 2017-06-08 10:59 qqky 阅读(187) 评论(0) 推荐(0)
摘要:题目描述 Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid. The brackets must close in the co 阅读全文
posted @ 2017-06-06 21:34 qqky 阅读(183) 评论(0) 推荐(0)
摘要:题目描述 Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after rai 阅读全文
posted @ 2017-06-06 21:18 qqky 阅读(189) 评论(0) 推荐(0)
摘要:题目描述 Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring. For"(()", the l 阅读全文
posted @ 2017-06-05 10:41 qqky 阅读(232) 评论(0) 推荐(0)
摘要:题目描述 Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the 阅读全文
posted @ 2017-06-04 10:47 qqky 阅读(155) 评论(0) 推荐(0)
摘要:题目描述 Evaluate the value of an arithmetic expression inReverse Polish Notation. Valid operators are+,-,*,/. Each operand may be an integer or another e 阅读全文
posted @ 2017-06-04 10:45 qqky 阅读(220) 评论(0) 推荐(0)
摘要:题目描述 Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. Afte 阅读全文
posted @ 2017-05-30 10:22 qqky 阅读(152) 评论(0) 推荐(0)
摘要:题目描述 Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 解题思路:借鉴于合并两个排序链表的题,采用分治法来解决该问题 不停的对半划分,比如k个链表先 阅读全文
posted @ 2017-05-30 09:52 qqky 阅读(208) 评论(0) 推荐(0)
摘要:题目描述 Given a linked list, swap every two adjacent nodes and return its head. For example, Given1->2->3->4, you should return the list as2->1->4->3. Yo 阅读全文
posted @ 2017-05-29 09:07 qqky 阅读(182) 评论(0) 推荐(0)
摘要:题目描述 Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k t 阅读全文
posted @ 2017-05-27 13:44 qqky 阅读(197) 评论(0) 推荐(0)
摘要:题目描述 You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a si 阅读全文
posted @ 2017-05-26 20:19 qqky 阅读(199) 评论(0) 推荐(0)
摘要:题目描述 There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity shoul 阅读全文
posted @ 2017-05-24 20:58 qqky 阅读(302) 评论(0) 推荐(0)
摘要:题目描述 Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinctnumbers from the original list. For example, Given 阅读全文
posted @ 2017-05-18 11:26 qqky 阅读(141) 评论(0) 推荐(0)
摘要:题目描述 Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve 阅读全文
posted @ 2017-05-17 10:48 qqky 阅读(280) 评论(0) 推荐(0)
摘要:题目描述 Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given1->1->2, return1->2. Given1->1->2->3- 阅读全文
posted @ 2017-05-16 08:58 qqky 阅读(152) 评论(0) 推荐(0)
摘要:题目描述 Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given1->2->3->4->5->NULL, m = 2 and n = 4,return1->4->3-> 阅读全文
posted @ 2017-05-15 16:49 qqky 阅读(319) 评论(0) 推荐(0)
摘要:题目描述 Merge 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 lists. 解题思 阅读全文
posted @ 2017-05-11 13:15 qqky 阅读(228) 评论(0) 推荐(0)
摘要:题目描述 Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given1->2->3->4->5->NULLand k =2, return4->5->1->2- 阅读全文
posted @ 2017-05-10 10:53 qqky 阅读(341) 评论(0) 推荐(0)
摘要:题目描述 Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. Follow up: Can you solve it without using extra sp 阅读全文
posted @ 2017-05-09 15:06 qqky 阅读(215) 评论(0) 推荐(0)
摘要:题目描述 Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 解题思路:使用快慢指针,若在遍历过程中slow==fast则有环,否则 阅读全文
posted @ 2017-05-08 14:59 qqky 阅读(137) 评论(0) 推荐(0)