随笔分类 -  LeetCode

上一页 1 ··· 47 48 49 50 51 52 53 54 55 ··· 61 下一页
摘要:Given 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 阅读全文
posted @ 2015-07-03 23:53 Grandyang 阅读(23549) 评论(10) 推荐(2) 编辑
摘要:Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Exampl 阅读全文
posted @ 2015-06-29 10:30 Grandyang 阅读(25039) 评论(5) 推荐(2) 编辑
摘要:Given the head of a linked list, remove the nth node from the end of the list and return its head. Example 1: Input: head = [1,2,3,4,5], n = 2 Output: 阅读全文
posted @ 2015-06-29 10:28 Grandyang 阅读(20245) 评论(15) 推荐(0) 编辑
摘要:Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. Note: The algorithm should run in linear time and in O(1) spa 阅读全文
posted @ 2015-06-29 09:52 Grandyang 阅读(25772) 评论(11) 推荐(0) 编辑
摘要:You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list 阅读全文
posted @ 2015-06-29 08:59 Grandyang 阅读(39622) 评论(14) 推荐(1) 编辑
摘要:Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The order of the elements may be changed. Then return  阅读全文
posted @ 2015-06-29 08:54 Grandyang 阅读(15350) 评论(0) 推荐(0) 编辑
摘要:Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Exampl 阅读全文
posted @ 2015-06-29 08:51 Grandyang 阅读(21570) 评论(2) 推荐(0) 编辑
摘要:Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the". Update (2015-02-12): For C 阅读全文
posted @ 2015-06-29 08:14 Grandyang 阅读(24601) 评论(2) 推荐(2) 编辑
摘要:Given a sorted integer array without duplicates, return the summary of its ranges. Example 1: Example 2: Credits:Special thanks to @jianchao.li.fighte 阅读全文
posted @ 2015-06-27 02:25 Grandyang 阅读(12672) 评论(6) 推荐(1) 编辑
摘要:Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negativeintegers, +, -, *, / operators an 阅读全文
posted @ 2015-06-25 23:13 Grandyang 阅读(26167) 评论(9) 推荐(1) 编辑
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the 阅读全文
posted @ 2015-06-19 03:10 Grandyang 阅读(29600) 评论(15) 推荐(2) 编辑
摘要:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. Example 1: Example 2: 这道题给了我们一堆二维点,然后让求最大的共线点的个数,根 阅读全文
posted @ 2015-06-16 04:37 Grandyang 阅读(20484) 评论(14) 推荐(1) 编辑
摘要:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is 阅读全文
posted @ 2015-06-15 05:49 Grandyang 阅读(25212) 评论(7) 推荐(1) 编辑
摘要:There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following re 阅读全文
posted @ 2015-06-14 14:21 Grandyang 阅读(24229) 评论(13) 推荐(1) 编辑
摘要:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by thi... 阅读全文
posted @ 2015-06-13 00:54 Grandyang 阅读(18775) 评论(3) 推荐(4) 编辑
摘要:Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or 阅读全文
posted @ 2015-06-12 02:30 Grandyang 阅读(27622) 评论(5) 推荐(1) 编辑
摘要:Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. to 阅读全文
posted @ 2015-06-11 12:49 Grandyang 阅读(13469) 评论(5) 推荐(0) 编辑
摘要:Given a complete binary tree, count the number of nodes. Note: Definition of a complete binary tree from Wikipedia:In a complete binary tree every lev 阅读全文
posted @ 2015-06-10 23:49 Grandyang 阅读(19225) 评论(7) 推荐(1) 编辑
摘要:Find the total area covered by two rectilinearrectangles in a 2D plane. Each rectangle is defined by its bottom left corner and top right corner as sh 阅读全文
posted @ 2015-06-09 12:56 Grandyang 阅读(10735) 评论(4) 推荐(0) 编辑
摘要:Given a 2D board containing 'X' and 'O'(the letter O), capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in t 阅读全文
posted @ 2015-06-05 23:55 Grandyang 阅读(22442) 评论(26) 推荐(0) 编辑

上一页 1 ··· 47 48 49 50 51 52 53 54 55 ··· 61 下一页
Fork me on GitHub