随笔分类 -  LeetCode

摘要:Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next... 阅读全文
posted @ 2015-01-18 08:33 Grandyang 阅读(15722) 评论(4) 推荐(0) 编辑
摘要:Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: Example 1: Example 2: Example 3: Credits:Spe 阅读全文
posted @ 2015-01-16 07:22 Grandyang 阅读(9701) 评论(4) 推荐(0) 编辑
摘要:Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A... 阅读全文
posted @ 2015-01-15 00:33 Grandyang 阅读(6174) 评论(3) 推荐(0) 编辑
摘要:Given a list of non negative integers, arrange them such that they form the largest number. Example 1: Example 2: Note: The result may be very large, 阅读全文
posted @ 2015-01-14 22:37 Grandyang 阅读(14159) 评论(4) 推荐(0) 编辑
摘要:Given an integer n, return the number of trailing zeroes in n!. Example 1: Example 2: Note: Your solution should be in logarithmic time complexity. Cr 阅读全文
posted @ 2015-01-12 21:33 Grandyang 阅读(13860) 评论(4) 推荐(0) 编辑
摘要:A peak element is an element that is strictly greater than its neighbors. Given an integer array nums, find a peak element, and return its index. If t 阅读全文
posted @ 2015-01-11 21:53 Grandyang 阅读(24574) 评论(14) 推荐(1) 编辑
摘要:Given a binary tree, return the preorder traversal of its nodes' values. Example: Input: [1,null,2,3] 1 \ 2 / 3 Output: [1,2,3] Follow up: Recursive s 阅读全文
posted @ 2014-12-05 16:29 Grandyang 阅读(15968) 评论(3) 推荐(3) 编辑
摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To represent a cycle in the given linked list, we use 阅读全文
posted @ 2014-12-02 14:10 Grandyang 阅读(23564) 评论(17) 推荐(1) 编辑
摘要:Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the posi 阅读全文
posted @ 2014-12-02 13:23 Grandyang 阅读(17293) 评论(3) 推荐(0) 编辑
摘要:Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runti 阅读全文
posted @ 2014-11-29 13:06 Grandyang 阅读(16459) 评论(7) 推荐(0) 编辑
摘要:Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each inp 阅读全文
posted @ 2014-11-29 10:43 Grandyang 阅读(159166) 评论(32) 推荐(14) 编辑
摘要:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes conta 阅读全文
posted @ 2014-11-29 05:57 Grandyang 阅读(53748) 评论(8) 推荐(2) 编辑
摘要:Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersec 阅读全文
posted @ 2014-11-28 14:40 Grandyang 阅读(22561) 评论(17) 推荐(1) 编辑
摘要:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font 阅读全文
posted @ 2014-11-28 13:03 Grandyang 阅读(26600) 评论(7) 推荐(1) 编辑
摘要:Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-2^ 阅读全文
posted @ 2014-11-27 09:04 Grandyang 阅读(33965) 评论(13) 推荐(1) 编辑
摘要:Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++'s atoi function). The algorithm for myAt 阅读全文
posted @ 2014-11-27 07:35 Grandyang 阅读(28945) 评论(4) 推荐(2) 编辑
摘要:Given an integer x, return true if x is a palindrome, and false otherwise. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from l 阅读全文
posted @ 2014-11-27 02:28 Grandyang 阅读(21730) 评论(7) 推荐(0) 编辑
摘要:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, two 阅读全文
posted @ 2014-11-26 15:26 Grandyang 阅读(23118) 评论(6) 推荐(0) 编辑
摘要:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, two 阅读全文
posted @ 2014-11-25 13:56 Grandyang 阅读(35095) 评论(6) 推荐(4) 编辑
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Remov 阅读全文
posted @ 2014-11-12 08:33 Grandyang 阅读(28591) 评论(5) 推荐(2) 编辑

Fork me on GitHub