
leetcode
文章平均质量分 69
mcrwayfun
这个作者很懒,什么都没留下…
展开
-
Baseball Game
Baseball GameDescriptionYou’re now a baseball game point recorder.Given a list of strings, each string can be one of the 4 following types:Integer (one round’s score): Directly represents t...原创 2018-08-07 08:58:24 · 209 阅读 · 0 评论 -
Find Minimum in Rotated Sorted Array
Find Minimum in Rotated Sorted ArrayDescriptionSuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,...原创 2018-07-03 11:22:37 · 151 阅读 · 0 评论 -
Single Number
Single NumberDescriptionGiven a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Cou...原创 2018-06-27 21:39:03 · 189 阅读 · 0 评论 -
Valid Palindrome
Valid PalindromeDescriptionGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note:For the purpose of this problem, we define empty ...原创 2018-06-27 21:37:55 · 1361 阅读 · 0 评论 -
Best Time to Buy and Sell Stock II
Best Time to Buy and Sell Stock IIDescriptionSay you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may comp...原创 2018-06-27 21:37:04 · 152 阅读 · 0 评论 -
Convert Sorted Array to Binary Search Tree
Convert Sorted Array to Binary Search TreeDescriptionGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary t...原创 2018-06-27 21:35:54 · 1428 阅读 · 0 评论 -
Maximum Depth of Binary Tree
Maximum Depth of Binary TreeDescriptionGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf ...原创 2018-06-27 21:34:59 · 191 阅读 · 0 评论 -
4Sum II
4Sum IIDescriptionGiven four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.To make problem a bit easier, all A,...原创 2018-06-27 20:34:10 · 4025 阅读 · 0 评论 -
Binary Tree Level Order Traversal
Binary Tree Level Order TraversalDescriptionGiven a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).Example 1: For example, Given ...原创 2018-06-26 23:21:46 · 196 阅读 · 0 评论 -
Symmetric Tree
Symmetric TreeDescriptionGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).Example 1: For example, this binary tree [1,2,2,3,4,4,3] is symmetric:...原创 2018-06-26 23:19:24 · 146 阅读 · 0 评论 -
Validate Binary Search Tree
Validate Binary Search TreeDescriptionGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows: - The left subtree of a node contains only n...原创 2018-06-26 23:17:33 · 3983 阅读 · 0 评论 -
Sqrt(x)
Sqrt(x)DescriptionImplement int sqrt(int x).Compute and return the square root of x, where x is guaranteed to be a non-negative integer.Since the return type is an integer, the decimal digits ...原创 2018-06-26 23:14:07 · 189 阅读 · 0 评论 -
Peak Index in a Mountain Array
Peak Index in a Mountain ArrayDescriptionLet’s call an array A a mountain if the following properties hold:A.length >= 3There exists some 0 < i < A.length - 1 such that A[0] < A[...原创 2018-06-19 17:24:14 · 4367 阅读 · 0 评论 -
Split Linked List in Parts
Split Linked List in PartsDescriptionGiven a (singly) linked list with head node root, write a function to split the linked list into k consecutive linked list “parts”.The length of each part ...原创 2018-07-17 00:38:55 · 209 阅读 · 0 评论 -
Contains Duplicate
Contains DuplicateDescriptionGiven 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 sho...原创 2018-07-17 00:50:18 · 201 阅读 · 0 评论 -
Intersection of Two Linked Lists
Intersection of Two Linked ListsDescriptionWrite a program to find the node at which the intersection of two singly linked lists begins.Example 1:A: a1 → a2 ↘ ...原创 2018-07-15 18:58:25 · 205 阅读 · 0 评论 -
Remove Linked List Elements
Remove Linked List ElementsDescriptionRemove all elements from a linked list of integers that have value val.Example 1:Input: 1->2->6->3->4->5->6, val = 6Output: 1->...原创 2018-07-14 18:15:54 · 178 阅读 · 0 评论 -
First Bad Version
First Bad VersionDescriptionYou are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each...原创 2018-07-19 23:35:06 · 226 阅读 · 0 评论 -
Valid Anagram
Valid AnagramDescriptionGiven two strings s and t , write a function to determine if t is an anagram(相同字母异序词) of s.Example 1:Input: s = "anagram", t = "nagaram"Output: trueExample 2:...原创 2018-07-19 23:34:01 · 197 阅读 · 0 评论 -
Delete Node in a Linked List
Delete Node in a Linked ListDescriptionWrite a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3...原创 2018-07-19 23:32:45 · 196 阅读 · 0 评论 -
Find Peak Element
Find Peak ElementDescriptionA peak element is an element that is greater than its neighbors.Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return its index.The...原创 2018-07-12 09:42:38 · 860 阅读 · 0 评论 -
Reverse a singly linked list
Reverse a singly linked listDescriptionGiven a linked list, remove the n-th node from the end of list and return its head.Example1:Input: 1-&gt;2-&gt;3-&gt;4-&gt;5-&gt;NULLOutput: 5-&gt;4...原创 2018-07-05 01:09:04 · 496 阅读 · 0 评论 -
Rotate Array
Rotate ArrayDescriptionGiven an array, rotate the array to the right by k steps, where k is non-negative.Example 1:Input: [1,2,3,4,5,6,7] and k = 3Output: [5,6,7,1,2,3,4]Explanation:rotat...原创 2018-07-05 01:07:32 · 163 阅读 · 0 评论 -
Linked List Cycle
Linked List CycleDescriptionGiven a linked list, determine if it has a cycle in it.Tags: LinkedList解读题意判断该链表是不是存不存在环思路1定义两个指针,一个快一个慢。快指针每次移动两步,慢指针移动一步,若快慢指针在某处重合,则说明存在环。class...原创 2018-07-05 01:05:35 · 147 阅读 · 0 评论 -
Kth Smallest Element in a BST
Kth Smallest Element in a BSTDescriptionGiven a binary search tree, write a function kthSmallest to find the kth smallest element in it.**Note:**You may assume k is always valid, 1 ≤ k ≤ BST’s...原创 2018-06-29 00:03:36 · 1337 阅读 · 0 评论 -
Find Right Interval
Find Right IntervalDescriptionGiven a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point of the interval...原创 2018-07-11 08:51:35 · 175 阅读 · 0 评论 -
Palindrome Linked List
Palindrome Linked ListDescriptionGiven a singly linked list, determine if it is a palindrome.Example1:Input: 1-&amp;amp;gt;2Output: falseExample2:Input: 1-&amp;amp;gt;2-&amp;amp;gt;2-&amp;amp;gt;1Output:原创 2018-07-17 00:51:55 · 202 阅读 · 0 评论 -
Merge Sorted Array
Merge Sorted ArrayDescriptionGiven two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and...原创 2018-06-25 21:57:49 · 218 阅读 · 0 评论 -
Rotate Image
DescriptionYou are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Example 1:Given input matrix = [ [1,2,3], [4,5,6], [7,8,9]],rotate t...原创 2018-06-25 21:56:43 · 3964 阅读 · 0 评论 -
Remove Nth Node From End of List
Remove Nth Node From End of ListDescriptionGiven a linked list, remove the n-th node from the end of list and return its head.Example1:Given linked list: 1-&gt;2-&gt;3-&gt;4-&gt;5, and n =...原创 2018-06-21 23:48:52 · 3533 阅读 · 0 评论 -
Longest Common Prefix
Longest Common PrefixDescriptionWrite 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 1:In...原创 2018-06-21 23:47:39 · 128 阅读 · 0 评论 -
String to Integer
String to IntegerDescriptionImplement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character i...原创 2018-06-21 23:46:44 · 290 阅读 · 0 评论 -
Reverse Integer
Reverse IntegerDescriptionReverse IntegerExample 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21note Assume we are dealing with an ...原创 2018-06-21 23:44:33 · 2373 阅读 · 0 评论 -
Two Sum
Two SumDescriptionGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you...原创 2018-06-21 23:43:32 · 187 阅读 · 0 评论 -
Find Smallest Letter Greater Than Target
Find Smallest Letter Greater Than TargetDescriptionGiven a list of sorted characters letters containing only lowercase letters, and given a target letter target, find the smallest element in the...原创 2018-06-21 23:41:21 · 576 阅读 · 0 评论 -
Two Sum II - Input array is sorted
Two Sum II - Input array is sortedDescriptionGiven 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 functi...原创 2018-06-21 17:17:40 · 3875 阅读 · 0 评论 -
Binary Tree Level Order Traversal
Binary Tree Level Order TraversalDescriptionGiven a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).Example 1: For example, Given ...原创 2018-06-06 22:15:00 · 3489 阅读 · 0 评论 -
Intersection of Two Arrays II
Intersection of Two Arrays IIDescriptionGiven two arrays, write a function to compute their intersection.Note - Each element in the result should appear as many times as it shows in both arra...原创 2018-06-20 23:21:13 · 131 阅读 · 0 评论 -
Intersection of Two Arrays
Intersection of Two ArraysDescriptionGiven two arrays, write a function to compute their intersection.Note - Each element in the result must be unique. - The result can be in any order.Exa...原创 2018-06-20 23:20:06 · 141 阅读 · 0 评论 -
leetCode汇总
java-leet-code每天一道leetCode,保持思维活跃explore(27) # Title Tag 001 Two Sum Array HashTable 007 Reverse Integer String 008 String to Integer String Array 014 Lo...原创 2018-06-05 23:38:32 · 9287 阅读 · 0 评论