随笔分类 -  LeetCode

摘要: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 阅读(29249) 评论(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 阅读(22068) 评论(8) 推荐(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 阅读(23496) 评论(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 阅读(35442) 评论(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 阅读(29123) 评论(5) 推荐(2)
摘要:The count-and-say sequence is a sequence of digit strings defined by the recursive formula: countAndSay(1) = "1" countAndSay(n) is the way you would " 阅读全文
posted @ 2014-11-10 05:10 Grandyang 阅读(20357) 评论(1) 推荐(1)
摘要:Given a string s consisting of words and spaces, return the length of the last word in the string. A word is a maximal substring consisting of non-spa 阅读全文
posted @ 2014-11-10 03:42 Grandyang 阅读(10511) 评论(0) 推荐(0)
摘要:You are given the heads of two sorted linked lists list1 and list2. Merge the two lists into one sorted list. The list should be made by splicing toge 阅读全文
posted @ 2014-11-10 03:22 Grandyang 阅读(27575) 评论(6) 推荐(3)
摘要:Given two binary strings a and b, return their sum as a binary string. Example 1: Input: a = "11", b = "1" Output: "100" Example 2: Input: a = "1010", 阅读全文
posted @ 2014-11-09 12:59 Grandyang 阅读(18526) 评论(5) 推荐(0)
摘要:A valid number can be split up into these components (in order): A decimal number or an integer. (Optional) An 'e' or 'E', followed by an integer. A d 阅读全文
posted @ 2014-11-09 08:22 Grandyang 阅读(21599) 评论(5) 推荐(1)
摘要:You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered fro 阅读全文
posted @ 2014-11-06 17:01 Grandyang 阅读(22251) 评论(2) 推荐(0)
摘要:You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb 阅读全文
posted @ 2014-11-06 16:09 Grandyang 阅读(19369) 评论(16) 推荐(0)
摘要:Given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the 阅读全文
posted @ 2014-11-02 12:47 Grandyang 阅读(14895) 评论(7) 推荐(0)
摘要:Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well. Example 阅读全文
posted @ 2014-11-01 09:43 Grandyang 阅读(11919) 评论(5) 推荐(0)
摘要:You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in num 阅读全文
posted @ 2014-10-29 15:25 Grandyang 阅读(21412) 评论(3) 推荐(1)
摘要:Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally ident 阅读全文
posted @ 2014-10-27 07:54 Grandyang 阅读(14519) 评论(6) 推荐(0)
摘要:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: But the fol 阅读全文
posted @ 2014-10-26 10:49 Grandyang 阅读(17485) 评论(17) 推荐(2)
摘要:Given 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 l 阅读全文
posted @ 2014-10-26 07:32 Grandyang 阅读(22379) 评论(9) 推荐(0)
摘要:Given the root of a binary tree, return the bottom-up level order traversal of its nodes' values. (i.e., from left to right, level by level from leaf 阅读全文
posted @ 2014-10-26 05:23 Grandyang 阅读(14097) 评论(1) 推荐(0)
摘要:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree {3 阅读全文
posted @ 2014-10-26 04:57 Grandyang 阅读(29156) 评论(11) 推荐(2)

Fork me on GitHub