- 博客(38)
- 资源 (15)
- 问答 (1)
- 收藏
- 关注
原创 [LeetCode]Find Peak Element
A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its index. The array may contain multiple peaks,
2015-02-21 20:54:44 888 3
原创 [LeetCode]Fraction to Recurring Decimal
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in parentheses.
2015-02-15 22:19:57 887
原创 [LeetCode]Binary Search Tree Iterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the next smallest number in the BST. Note
2015-02-15 16:58:17 709
原创 [LeetCode]Largest Number
Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330. Note: The result m
2015-02-14 21:48:30 707
原创 [LeetCode]Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. For example: Given the below binary tree, 1 / \
2015-02-14 14:47:33 531
原创 [LeetCode]Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree.这道题与上一题类似, 要求根据二叉树的后序遍历序列和中序遍历序列构建二叉树。后序遍历序列的末尾是根节点,在中
2015-02-14 13:33:32 644
原创 [LeetCode]Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree.这道题要求根据二叉树的前序遍历序列和中序遍历序列构建二叉树。 举个例子: 前序序列:A B D E F C
2015-02-14 13:06:53 596
原创 [LeetCode]Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1
2015-02-13 22:03:45 403
原创 [LeetCode]Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root). For example: Given binary tree {3,9,20,#
2015-02-13 20:49:32 451
原创 [LeetCode]Maximum Depth of Binary Tree
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 leaf node.这道题是求一个二叉树的深度。题目中对深度的定义是:从根节点到叶节点依次经
2015-02-13 20:05:31 539
原创 [LeetCode]Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between). For example: Giv
2015-02-13 19:46:46 530
原创 [LeetCode]Binary Tree Level Order Traversal
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,9,20,#,#,15,7}, 3
2015-02-13 18:28:20 696
原创 [LeetCode]Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3
2015-02-13 16:40:24 535
原创 [LeetCode]Reverse Words in a String
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 programmers: Try to
2015-02-12 21:35:38 392
原创 [LeetCode]Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.这道题是让合并两个有序链表。增设一个头结点。下面贴上代码:#include <iostream>using name
2015-02-12 20:50:21 483
原创 [LeetCode]Balanced Binary Tree
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 depth of the two subtrees of every node never diff
2015-02-12 20:19:13 563
原创 [LeeCode]Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of last word in the string. If the last word does not exist, return 0. Note: A wor
2015-02-12 16:40:48 537
原创 [LeetCode]Count and Say
The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, … 1 is read off as “one 1” or 11. 11 is read off as “two 1s” or 21. 21 is re
2015-02-12 16:26:51 473
原创 [LeetCode]Minimum Depth of Binary Tree
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 leaf node.这道题是让求出一棵二叉树中的最短路径的长度。很显然,它的思路与求树的深度
2015-02-12 15:10:43 517
原创 [LeetCode]Pascal's Triangle II
Given an index k, return the kth row of the Pascal’s triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space?这道题要求输出杨辉三角的
2015-02-09 15:19:51 474
原创 [LeetCode]Pascal's Triangle
Given numRows, generate the first numRows of Pascal’s triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]这道题很简单,就
2015-02-09 13:58:13 590
原创 [LeetCode]Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, “A man, a plan, a canal: Panama” is a palindrome. “race a car” is not
2015-02-09 13:36:23 511
原创 [LeetCode]Excel Sheet Column Number
Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3
2015-02-09 12:52:20 384
原创 [LeetCode]Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() –
2015-02-09 12:50:26 548
原创 [LeetCode]Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: A: a1 → a2 ↘
2015-02-07 22:14:54 559
原创 [LeetCode]Compare Version Numbers
Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may assume that the version strings are non-empty and
2015-02-07 21:54:31 496
原创 [LeetCode]Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element a
2015-02-07 13:32:44 482
原创 [LeetCode]Excel Sheet Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example:1 -> A2 -> B3 -> C...26 -> Z27 -> AA28 -> AB 这道题是Excel Sheet Column Number的反转。 与一般的N进制的
2015-02-07 12:31:12 489
原创 [LeetCode]Factorial Trailing Zeroes
Q:Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.给定一个整数n,返回n!的结果中后缀0的个数,解法的时间复杂度要满足对数时间复杂度。如果不考虑时间复杂度问题,最简单的方法就
2015-02-05 13:52:28 481
原创 [LeetCode]Search for a Range
Q:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is not foun
2015-02-05 12:46:30 550
原创 [LeetCode]Search Insert Position
Q:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the ar
2015-02-05 11:28:26 358
原创 [LeetCode]Implement strStr()
Q:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.这道题是让我们自己完善函数strStr():返回模式串needle在主串haystack中第一次出现的索引位置,若主串中不存在模式串
2015-02-05 10:10:58 518
原创 [LeetCode]Valid Parentheses
Q:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all
2015-02-04 20:34:54 465
原创 [LeetCode]Remove Nth Node From End of List
Q:Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the
2015-02-03 12:25:25 510
原创 [LeetCode]Longest Common Prefix
Q:Write a function to find the longest common prefix string amongst an array of strings.这道题是要求一组字符串的最长相同前缀。思路很简单,一个一个扫描。两种特殊情况如下:1.若strs为空,则返回空字符串2.若strs只含有一个字符串,则返回该字符串下面为一般情况:依次取strs[0]的前1
2015-02-03 10:53:12 508
原创 [LeetCode]Roman to Integer
Q:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.该题是要将罗马数字转换成integer。罗马数字的定义可见维基百科:Roman numerals .罗马数字是基于下面7个符号:罗马数字的1
2015-02-03 10:19:45 569
原创 [LeetCode]Add Two Numbers
Q:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as
2015-02-02 22:39:19 498
原创 [LeetCode]Longest Substring Without Repeating Characters
Q:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3.
2015-02-01 18:25:02 516
commons-collections.jar
2016-03-19
Head First Servlets and JSP 2nd Edition.Mar.2008
2014-07-21
Objective-C Programming- The Big Nerd Ranch Guide, 2 edition
2014-04-20
关于clojure中的some函数问题
2016-08-29
TA创建的收藏夹 TA关注的收藏夹
TA关注的人