Leetcode
文章平均质量分 63
BYR_LJK
菜鸟
展开
-
402.Remove K Digits
题目: Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: The length of num is less than 10002 a原创 2016-10-16 16:51:48 · 139 阅读 · 0 评论 -
219. Contains Duplicate II
题目: Given an array of integers and an integer k, find out whether there are two distinct indices iand j in the array such that nums[i] = nums[j] and the difference between i and j is at mostk原创 2016-11-08 23:39:49 · 171 阅读 · 0 评论 -
88. Merge Sorted Array
题目: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 has enough space (size that is greater or equal to m + n) to h原创 2016-11-08 23:35:18 · 189 阅读 · 0 评论 -
169. Majority Element
题目: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority原创 2016-11-08 23:29:27 · 164 阅读 · 0 评论 -
64. Minimum Path Sum
题目: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or原创 2016-11-08 23:22:15 · 175 阅读 · 0 评论 -
86. Partition List
题目: 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 the original relative order of the nodes i原创 2016-10-04 19:54:02 · 189 阅读 · 0 评论 -
82. Remove Duplicates from Sorted List II
题目: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Given 1->2->3->3->4->4->5, return 1->2->5. Gi原创 2016-10-04 19:33:52 · 178 阅读 · 0 评论 -
61. Rotate List
题目: Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL. 题目分析: 1、边界情况:k原创 2016-10-04 19:25:10 · 170 阅读 · 0 评论 -
160. Intersection of Two Linked Lists
题目: Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: A: a1 → a2 ↘原创 2016-10-02 10:23:25 · 180 阅读 · 0 评论 -
143. Reorder List
题目: Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For example, Given {1,2,3,4}, reord原创 2016-10-02 10:48:52 · 153 阅读 · 0 评论 -
142. Linked List Cycle II
题目: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. 题目分析: 1、边界情况:量表为空;只有一个节点,指向本节点 2、必须先知道链表存在不存在环(快慢指原创 2016-10-04 16:25:22 · 165 阅读 · 0 评论 -
92. Reverse Linked List II
题目: Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note: Given m, n sa原创 2016-10-04 17:29:31 · 180 阅读 · 0 评论 -
2. Add Two Numbers
题目: 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 single digit. Add the two numbers and return原创 2016-10-04 17:41:08 · 251 阅读 · 0 评论 -
328. Odd Even Linked List
题目: Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. You should try to原创 2016-10-04 18:01:36 · 202 阅读 · 0 评论 -
448. Find All Numbers Disappeared in an Array
题目: Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this a原创 2016-11-07 23:26:39 · 142 阅读 · 0 评论 -
167. Two Sum II - Input array is sorted
题目: Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the t原创 2016-11-07 23:17:21 · 190 阅读 · 0 评论 -
71.Simplify Path
题目: Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/", => "/home" path = "/a/./b/../../c/", => "/c" 思路: 1、边界情况:如果只输入'/':直接返回"/"即可 2、做这道题需原创 2016-10-16 11:45:19 · 221 阅读 · 0 评论 -
234. Palindrome Linked List
题目: Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) space? 题目分析: 1、边界情况:链表为空或者链表长度为1 2、判断回文方法:将后半段翻转,与前半段比较,相同即回文 思路:原创 2016-10-08 14:18:39 · 168 阅读 · 0 评论