自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(63)
  • 资源 (1)
  • 收藏
  • 关注

原创 106. Construct Binary Tree from Inorder and Postorder Traversal

Given inorder and postorder traversal of a tree, construct the binary tree.注意左子树在后序中的根的位置为:root - (end - pos + 1), 根的位置-右子树的个数/** * Definition for a binary tree node. * struct TreeNode { * int v

2017-02-26 14:50:56 182

原创 105. Construct Binary Tree from Preorder and Inorder Traversal

Given preorder and inorder traversal of a tree, construct the binary tree./** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right;

2017-02-26 14:31:43 251

原创 108. Convert Sorted Array to Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; *

2017-02-25 11:21:26 166

原创 编程之美3-11程序改错

二分查找你针对有序序列而言的一种查找算法,关于二分查找有一下的几类问题: 1. 给定一个有序(不降序)数组arr,求任意一个i使得arr[i]等于v,不存在则返回-1#include <iostream> using namespace std; int binarySearch(int A[], int left, int right, int t) { int m; while

2017-02-24 21:33:08 286

转载 201. Bitwise AND of Numbers Range

Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.For example, given the range [5, 7], you should return 4. 思路:http://www.cnblogs.com

2017-02-24 13:35:50 287

原创 216. Combination Sum III

Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.Example 1:Input: k = 3, n =

2017-02-24 11:19:24 202

原创 78. Subsets

Given a set of distinct integers, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example, If nums = [1,2,3], a solution is:[ [3], [1], [2], [1,

2017-02-24 10:39:13 181

原创 89. Gray Code

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 number of bits in the code, print the sequence of gray

2017-02-24 10:29:56 376

原创 74. Search a 2D Matrix

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 from left to right. The first integer of each row is

2017-02-23 16:59:14 179

原创 73. Set Matrix Zeroes

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 space? A straight forward solution using O(mn) space

2017-02-23 16:32:12 172

原创 520. Detect Capital

Given a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of the following cases holds:All letters in this word

2017-02-22 11:55:34 255

原创 215. Kth Largest Element in an Array

Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example, Given [3,2,1,5,6,4] and k = 2, return 5.Note:

2017-02-22 11:36:36 162

原创 414. Third Maximum Number

Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).Example 1:Input: [3, 2, 1]Output

2017-02-22 10:59:35 301

原创 347. Top K Frequent Elements

Given a non-empty array of integers, return the k most frequent elements.For example, Given [1,1,1,2,2,3] and k = 2, return [1,2].Note: You may assume k is always valid, 1 ≤ k ≤ number of unique ele

2017-02-22 10:35:30 193

原创 451. Sort Characters By Frequency

Given a string, sort it in decreasing order based on the frequency of characters.Example 1:Input: "tree"Output: "eert"Explanation: 'e' appears twice while 'r' and 't' both appear once. So 'e' must appe

2017-02-22 10:04:02 175

原创 442. Find All Duplicates in an Array

Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without extra space

2017-02-21 20:27:59 157

原创 423. Reconstruct Original Digits from English

Given a non-empty string containing an out-of-order English representation of digits 0-9, output the digits in ascending order.Note: Input contains only lowercase English letters. Input is guaranteed

2017-02-21 19:58:05 187

转载 421. Maximum XOR of Two Numbers in an Array

Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231.Find the maximum result of ai XOR aj, where 0 ≤ i, j < n.Could you do this in O(n) runtime?Example:Input: [3, 10, 5, 25, 2,

2017-02-21 13:01:46 190

原创 419. Battleships in a Board

Given an 2D board, count how many battleships are in it. The battleships are represented with ‘X’s, empty slots are represented with ‘.’s. You may assume the following rules:You receive a valid board,

2017-02-21 10:57:14 228

原创 513. Find Bottom Left Tree Value

Given a binary tree, find the leftmost value in the last row of the tree.Example 1:Input: 2 / \ 1 3Output: 1Example 2: Input: 1 / \ 2 3 / / \ 4 5 6

2017-02-20 12:46:47 183

原创 515. Find Largest Value in Each Tree Row

You need to find the largest value in each row of a binary tree.Example:Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9]思路:dfs遍历,然后顺便记录每层的最大值/** * Defin

2017-02-20 11:39:10 223

原创 230. Kth Smallest Element in a BST

Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.Follow up: What if the BST is mod

2017-02-20 10:10:17 163

转载 287. Find the Duplicate Number

Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, fin

2017-02-19 20:25:15 157

原创 145. Binary Tree Postorder Traversal

Given a binary tree, return the postorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recursive solution is trivial, could

2017-02-19 19:02:08 163

原创 500. Keyboard Row

Given a List of words, return the words that can be typed using letters of alphabet on only one row’s of American keyboard like the image below. Example 1:Input: ["Hello", "Alaska", "Dad", "Peace"] Ou

2017-02-18 11:48:44 178

原创 496. Next Greater Element I

You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1’s elements in the corresponding places of nums2.The

2017-02-18 11:18:49 206

原创 492. Construct the Rectangle

For a web developer, it is very important to know how to design a web page’s size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L

2017-02-18 11:03:42 196

原创 485. Max Consecutive Ones

Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three digits are consecutive 1s.

2017-02-18 10:52:46 168

原创 476. Number Complement

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note: The given integer is guaranteed to fit within the range of a 32-b

2017-02-18 10:35:44 207

原创 501. Find Mode in Binary Search Tree

Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST.Assume a BST is defined as follows:The left subtree of a node contains onl

2017-02-17 11:36:29 410

原创 504. Base 7

Given an integer, return its base 7 string representation.Example 1:Input: 100 Output: "202"Example 2:Input: -7 Output: "-10"Note: The input will be in range of [-1e7, 1e7].class Solution { public:

2017-02-17 11:06:19 223

原创 506. Relative Ranks

Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: “Gold Medal”, “Silver Medal” and “Bronze Medal”.Example 1:Input: [5,

2017-02-17 10:21:33 366

原创 461. Hamming Distance

The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.Example:Input: x = 1, y = 4

2017-02-16 11:21:51 138

原创 459. Repeated Substring Pattern

Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase Englis

2017-02-16 11:12:06 211

原创 453. Minimum Moves to Equal Array Elements

Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.Example:Input: [1,2,3]Output: 3Ex

2017-02-16 09:34:55 155

原创 448. Find All Numbers Disappeared in an Array

Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.Could you

2017-02-15 11:35:45 146

原创 447. Number of Boomerangs

Given n points in the plane that are all pairwise distinct, a “boomerang” is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tup

2017-02-15 10:37:44 188

原创 441. Arranging Coins

You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.Given n, find the total number of full staircase rows that can be formed.n is a no

2017-02-14 11:27:04 145

原创 412. Fizz Buzz

Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For n

2017-02-13 11:04:14 194

原创 409. Longest Palindrome

Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example “Aa” is not consider

2017-02-13 10:52:17 142

sample.pcd

ubuntu16.04 pcl安装教程 https://blog.csdn.net/zkj126521/article/details/80157351

2018-05-01

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除