• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
xiaoba1203
记录leetcode之路
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理

10 2016 档案

 
leetcode 113 Path Sum II ----- java
摘要: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 @ 2016-10-29 17:54 xiaoba1203 阅读(264) 评论(0) 推荐(0)
leetcode 112 Path Sum ----- java
摘要: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. F 阅读全文
posted @ 2016-10-29 17:31 xiaoba1203 阅读(157) 评论(0) 推荐(0)
leetcode 111 Minimum Depth of Binary Tree ----- java
摘要: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 @ 2016-10-29 16:49 xiaoba1203 阅读(151) 评论(0) 推荐(0)
leetcode 110 Balanced Binary Tree ----- java
摘要: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 dept 阅读全文
posted @ 2016-10-29 16:39 xiaoba1203 阅读(147) 评论(0) 推荐(0)
leetcode 109 Convert Sorted List to Binary Search Tree ----- java
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 和上一题类似,把数组换成链表,所以可以两种做法: 1、把链表换成数组,然后用上一 阅读全文
posted @ 2016-10-29 16:18 xiaoba1203 阅读(173) 评论(0) 推荐(0)
leetcode 108 Convert Sorted Array to Binary Search Tree ----- java
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 给一个排好序的数组,然后求搜索二叉树 其实就是二分法,不难。 阅读全文
posted @ 2016-10-28 20:51 xiaoba1203 阅读(173) 评论(0) 推荐(0)
leetcode 107 Binary Tree Level Order Traversal II ----- java
摘要: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 阅读全文
posted @ 2016-10-28 18:10 xiaoba1203 阅读(208) 评论(0) 推荐(0)
leetcode 106 Construct Binary Tree from Inorder and Postorder Traversal----- java
摘要:Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 和上一道题基本一样 根据 阅读全文
posted @ 2016-10-28 17:59 xiaoba1203 阅读(146) 评论(0) 推荐(0)
leetcode 105 Construct Binary Tree from Preorder and Inorder Traversal ----- java
摘要:Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 给出前序遍历和中序遍历,然 阅读全文
posted @ 2016-10-28 17:35 xiaoba1203 阅读(366) 评论(0) 推荐(0)
leetcode 104 Maximum Depth of Binary Tree ----- java
摘要: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 @ 2016-10-26 11:45 xiaoba1203 阅读(174) 评论(0) 推荐(0)
leetcode 103 Binary Tree Zigzag Level Order Traversal ----- java
摘要: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 阅读全文
posted @ 2016-10-26 11:22 xiaoba1203 阅读(145) 评论(0) 推荐(0)
leetcode 102 Binary Tree Level Order Traversal ----- java
摘要: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 @ 2016-10-25 23:46 xiaoba1203 阅读(137) 评论(0) 推荐(0)
leetcode 99 Recover Binary Search Tree ----- java
摘要:Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note:A solution using O(n) space i 阅读全文
posted @ 2016-10-25 23:25 xiaoba1203 阅读(743) 评论(0) 推荐(0)
leetcode 101 Symmetric Tree ----- java
摘要:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmet 阅读全文
posted @ 2016-10-25 19:32 xiaoba1203 阅读(153) 评论(0) 推荐(0)
leetcode 100 Same Tree ----- java
摘要:Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical a 阅读全文
posted @ 2016-10-25 19:00 xiaoba1203 阅读(146) 评论(0) 推荐(0)
leetcode 98 Validate Binary Search Tree ----- java
摘要:Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only 阅读全文
posted @ 2016-10-25 18:16 xiaoba1203 阅读(355) 评论(0) 推荐(0)
leetcode 97 Interleaving String ----- java
摘要:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example,Given:s1 = "aabcc",s2 = "dbbca", When s3 = "aadbbcbcac", ret 阅读全文
posted @ 2016-10-25 16:25 xiaoba1203 阅读(228) 评论(0) 推荐(0)
leetcode 95 Unique Binary Search Trees II ----- java
摘要:Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should 阅读全文
posted @ 2016-10-21 18:46 xiaoba1203 阅读(179) 评论(0) 推荐(0)
leetcode 96 Unique Binary Search Trees ----- java
摘要:Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique BST' 阅读全文
posted @ 2016-10-20 22:45 xiaoba1203 阅读(118) 评论(0) 推荐(0)
leetcode 94 Binary Tree Inorder Traversal ----- java
摘要:Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree [1,null,2,3], return [1,3,2]. Note: Recursive so 阅读全文
posted @ 2016-10-20 19:02 xiaoba1203 阅读(212) 评论(0) 推荐(0)
leetcode 93 Restore IP Addresses ----- java
摘要:Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given "25525511135", return ["2 阅读全文
posted @ 2016-10-20 18:23 xiaoba1203 阅读(308) 评论(0) 推荐(0)
leetcode 92 Reverse Linked List II ----- java
摘要:Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2- 阅读全文
posted @ 2016-10-20 16:37 xiaoba1203 阅读(228) 评论(0) 推荐(0)
leetcode 91 Decode Ways ----- java
摘要:A message containing letters from A-Z is being encoded to numbers using the following mapping: Given an encoded message containing digits, determine t 阅读全文
posted @ 2016-10-20 15:19 xiaoba1203 阅读(311) 评论(0) 推荐(0)
leetcode 90 Subsets II ----- java
摘要:Given a collection of integers that might contain duplicates, nums, return all possible subsets. Note: The solution set must not contain duplicate sub 阅读全文
posted @ 2016-10-19 23:25 xiaoba1203 阅读(623) 评论(0) 推荐(0)
leetcode 89 Gray Code ----- java
摘要:The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total num 阅读全文
posted @ 2016-10-19 22:06 xiaoba1203 阅读(293) 评论(0) 推荐(0)
leetcode 88 Merge Sorted Array ----- java
摘要:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has enough space (size tha 阅读全文
posted @ 2016-10-19 22:04 xiaoba1203 阅读(143) 评论(0) 推荐(0)
leetcode 87 Scramble String ----- java
摘要:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representati 阅读全文
posted @ 2016-10-19 22:03 xiaoba1203 阅读(278) 评论(0) 推荐(0)
leetcode 85 Maximal Rectangle ----- java
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. For example, given the following 阅读全文
posted @ 2016-10-19 11:46 xiaoba1203 阅读(404) 评论(0) 推荐(0)
leetcode 86 Partition List ----- java
摘要:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the 阅读全文
posted @ 2016-10-19 11:15 xiaoba1203 阅读(152) 评论(0) 推荐(0)
leetcode 84 Largest Rectangle in Histogram ----- java
摘要:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist 阅读全文
posted @ 2016-10-18 23:17 xiaoba1203 阅读(142) 评论(0) 推荐(0)
leetcode 83 Remove Duplicates from Sorted List ----- java
摘要:Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, 阅读全文
posted @ 2016-10-18 19:06 xiaoba1203 阅读(130) 评论(0) 推荐(0)
leetcode 82 Remove Duplicates from Sorted List II ----- java
摘要:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example,Given 1->2 阅读全文
posted @ 2016-10-18 18:55 xiaoba1203 阅读(136) 评论(0) 推荐(0)
leetcode 81 Search in Rotated Sorted Array II ----- java
摘要:Follow up for "Search in Rotated Sorted Array": Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the 阅读全文
posted @ 2016-10-18 18:15 xiaoba1203 阅读(216) 评论(0) 推荐(0)
leetcode 80 Remove Duplicates from Sorted Array II ----- java
摘要:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For example,Given sorted array nums = [1,1,1,2,2,3], Your function sho 阅读全文
posted @ 2016-10-16 18:02 xiaoba1203 阅读(228) 评论(0) 推荐(0)
leetcode 79 Word Search ----- java
摘要:Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjac 阅读全文
posted @ 2016-10-16 17:40 xiaoba1203 阅读(690) 评论(0) 推荐(0)
leetcode 78 Subsets ----- java
摘要:Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example,If nums =  阅读全文
posted @ 2016-10-16 16:32 xiaoba1203 阅读(227) 评论(0) 推荐(0)
leetcode 77 Combinations ----- java
摘要:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example,If n = 4 and k = 2, a solution is: 求C(k,n)的所有结果。 阅读全文
posted @ 2016-10-16 16:20 xiaoba1203 阅读(286) 评论(0) 推荐(0)
leetcode 76 Minimum Window Substring ----- java
摘要:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example,S = "ADOBECOD 阅读全文
posted @ 2016-10-16 13:57 xiaoba1203 阅读(239) 评论(0) 推荐(0)
leetcode 75 Sort Colors ----- java
摘要:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, 阅读全文
posted @ 2016-10-15 23:30 xiaoba1203 阅读(161) 评论(0) 推荐(0)
leetcode 74 Search a 2D Matrix ----- java
摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted f 阅读全文
posted @ 2016-10-15 21:55 xiaoba1203 阅读(230) 评论(0) 推荐(0)
leetcode 73 Set Matrix Zeroes ----- java
摘要:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. Follow up: Did you use extra sp 阅读全文
posted @ 2016-10-15 18:32 xiaoba1203 阅读(572) 评论(0) 推荐(0)
leetcode 72 Edit Distance ----- java
摘要:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have 阅读全文
posted @ 2016-10-15 16:47 xiaoba1203 阅读(180) 评论(0) 推荐(0)
leetcode 71 Simplify Path ------ java
摘要:Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c" click to show co 阅读全文
posted @ 2016-10-14 01:26 xiaoba1203 阅读(248) 评论(0) 推荐(0)
leetcode 70 Climbing Stairs ----- java
摘要:You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl 阅读全文
posted @ 2016-10-12 22:37 xiaoba1203 阅读(181) 评论(0) 推荐(0)
leetcode 69 Sqrt(x) ---java
摘要:Implement int sqrt(int x). Compute and return the square root of x. 求一个数的平方根。 其实就是一个二分查找。 有两种查找方式 1、就是找到最大int值,然后从0到max,二分查找。 2、直接针对x,从0到x,二分查找。 阅读全文
posted @ 2016-10-12 22:10 xiaoba1203 阅读(234) 评论(0) 推荐(0)
leetcode 68 Text Justification ----- java
摘要:Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You shou 阅读全文
posted @ 2016-10-12 00:02 xiaoba1203 阅读(178) 评论(0) 推荐(0)
leetcode 67 Add Binary ----- java
摘要:Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 两个二进制数相加,并不难。 阅读全文
posted @ 2016-10-11 18:34 xiaoba1203 阅读(140) 评论(0) 推荐(0)
leetcode 66 Plus One ----- java
摘要:Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is a 阅读全文
posted @ 2016-10-11 15:41 xiaoba1203 阅读(142) 评论(0) 推荐(0)
leetcode 65 Valid Number ----- java
摘要:Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => true Note: It is intended for the 阅读全文
posted @ 2016-10-11 15:11 xiaoba1203 阅读(160) 评论(0) 推荐(0)
leetcode 64 Minimum Path Sum ----- java
摘要:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. 阅读全文
posted @ 2016-10-11 12:36 xiaoba1203 阅读(162) 评论(0) 推荐(0)
leetcode 63 Unique Paths II ---java
摘要:Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space 阅读全文
posted @ 2016-10-11 12:08 xiaoba1203 阅读(155) 评论(0) 推荐(0)
leetcode 62 Unique Paths ---java
摘要:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2016-10-10 23:44 xiaoba1203 阅读(174) 评论(0) 推荐(0)
leetcode 61 Rotate List ----- java
摘要:Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3- 阅读全文
posted @ 2016-10-08 22:49 xiaoba1203 阅读(171) 评论(0) 推荐(0)
 

公告


博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3