随笔分类 - 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
阅读全文
摘要:题目描述 Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid. The brackets must close in the co
阅读全文
摘要:题目描述 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
阅读全文
摘要:题目描述 Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring. For"(()", the l
阅读全文
摘要:题目描述 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
阅读全文
摘要:题目描述 Evaluate the value of an arithmetic expression inReverse Polish Notation. Valid operators are+,-,*,/. Each operand may be an integer or another e
阅读全文
摘要:题目描述 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
阅读全文
摘要:题目描述 Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 解题思路:借鉴于合并两个排序链表的题,采用分治法来解决该问题 不停的对半划分,比如k个链表先
阅读全文
摘要:题目描述 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
阅读全文
摘要:题目描述 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
阅读全文
摘要:题目描述 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
阅读全文
摘要:题目描述 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
阅读全文
摘要:题目描述 Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinctnumbers from the original list. For example, Given
阅读全文
摘要:题目描述 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
阅读全文
摘要:题目描述 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-
阅读全文
摘要:题目描述 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->
阅读全文
摘要:题目描述 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. 解题思
阅读全文
摘要:题目描述 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-
阅读全文
摘要:题目描述 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
阅读全文
摘要:题目描述 Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 解题思路:使用快慢指针,若在遍历过程中slow==fast则有环,否则
阅读全文

浙公网安备 33010602011771号