随笔分类 -  LeetCode

摘要: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 阅读(20097) 评论(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 阅读(10315) 评论(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 阅读(27055) 评论(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 阅读(18252) 评论(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 阅读(21336) 评论(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 阅读(22025) 评论(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 阅读(18974) 评论(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 阅读(14553) 评论(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 阅读(11687) 评论(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 阅读(20978) 评论(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 阅读(14277) 评论(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 阅读(17259) 评论(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 阅读(21986) 评论(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 阅读(13933) 评论(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 阅读(28578) 评论(11) 推荐(2) 编辑
摘要:Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the dep 阅读全文
posted @ 2014-10-23 13:59 Grandyang 阅读(17973) 评论(7) 推荐(0) 编辑
摘要:Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l 阅读全文
posted @ 2014-10-22 07:27 Grandyang 阅读(18851) 评论(5) 推荐(3) 编辑
摘要:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example:Given the below binary tree and sum 阅读全文
posted @ 2014-10-22 06:45 Grandyang 阅读(18852) 评论(6) 推荐(1) 编辑
摘要:Suppose 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,2]). F 阅读全文
posted @ 2014-10-21 15:15 Grandyang 阅读(11165) 评论(4) 推荐(0) 编辑
摘要:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. N 阅读全文
posted @ 2014-10-20 13:08 Grandyang 阅读(17815) 评论(4) 推荐(0) 编辑

Fork me on GitHub