自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(185)
  • 收藏
  • 关注

原创 股票交易

题目描述Say you have an array for which the i th element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most two transactions. Note: You ...

2017-09-05 21:40:29 471

原创 word-break-ii

Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. For example, given s =”catsan

2017-08-29 22:44:17 350

原创 single-number-ii

题目描述Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without u

2017-07-28 22:12:48 449

原创 微软夏令营笔试测验第一题 Array Partition

时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Given an integer array A1, A2 … AN, you are asked to split the array into three continuous parts: A1, A2 … Ap | Ap+1, Ap+2, … Aq | Aq+1, Aq+2, … AN.Let S1, S2

2017-07-20 13:18:51 549

原创 微软夏令营编程测验第二题MSFT

时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Ho has a string S consisting of only lowercase letters.All letters in S are distinct except for ‘m’, ‘s’, ‘f’ and ‘t’. Which means the four magical let

2017-07-20 11:30:38 487

原创 construct-binary-tree-from-preorder-and-inorder

Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree./** * Definition for binary tree * struct TreeNode { *

2017-05-24 22:05:02 348

原创 n-queens

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle. Each sol

2017-05-22 11:46:28 371

原创 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./** * Definition for singly-linked list. * struct List

2017-05-22 10:23:53 402

原创 anagrams

Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case题目的意思是如果字符串容器中存在同构词(包含相同字母),则将同构词保存下来,需要的注意的是第一次出现的单词的处理.class Solution {public: v

2017-05-04 22:58:14 336

原创 minimum-window-substring

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 =”ADOBECODEBANC” T =”ABC” Minimum window is”BANC”. Note:

2017-05-04 21:22:52 370

原创 remove-duplicates-from-sorted-list-ii

题目描述Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Given1->2->3->3->4->4->5, return1->2->5. Given1->1->1

2017-04-28 11:11:56 270

原创 百度2017实习编程题

[编程题] 寻找三角形 时间限制:1秒 空间限制:32768K 三维空间中有N个点,每个点可能是三种颜色的其中之一,三种颜色分别是红绿蓝,分别用’R’, ‘G’, ‘B’表示。 现在要找出三个点,并组成一个三角形,使得这个三角形的面积最大。 但是三角形必须满足:三个点的颜色要么全部相同,要么全部不同。 输入描述: 首先输入一个正整数N三维坐标系内的点的个数.(N <= 50) 接下

2017-04-27 21:43:55 2946

原创 jump-game

题目描述Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if

2017-04-27 10:33:21 351

原创 plus-one

Given a number represented as an array of digits, plus one to the number.easy~class Solution {public: vector<int> plusOne(vector<int> &digits) { int len=digits.size(); if(len<=0)

2017-04-26 22:30:28 417

原创 remove-duplicates-from-sorted-list

题目描述Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given1->1->2, return1->2. Given1->1->2->3->3, return1->2->3./** * Definition for singly-l

2017-04-26 22:05:14 317

原创 add-binary

Given two binary strings, return their sum (also a binary string). For example, a =”11” b =”1” Return”100”. 模拟即可class Solution {public: string addBinary(string a, string b) { string r

2017-04-26 16:41:12 323

原创 最小路径和

题目描述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. Note: You can only move either down or right a

2017-04-26 14:33:00 303

原创 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(

2017-04-26 13:26:20 448

原创 sort-colors

题目描述 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, white and blue. Here, we will use the intege

2017-04-25 15:44:19 399

原创 unique-binary-search-trees-ii

Given n, generate all structurally unique BST’s (binary search trees) that store values 1…n. For example, Given n = 3, your program should return all 5 unique BST’s shown below. 1 3 3

2017-04-25 00:13:52 281

原创 unique-binary-search-trees

题目描述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’s. 1 3 3 2 1 \

2017-04-24 22:07:50 390

原创 华为fx测试题

1. 小K是X区域的销售经理,他平常常驻“5”城市,并且经常要到“1”、“2”、“3”、“4”、“6”城市出差。当机场出现大雾情况时,会导致对应城市的所有航班的起飞及降落均停止(即不能从该城市出发,其他城市也不能到达该城市)。小K希望知道如果他需要到X城市出差时,如果遇到Y城市出现大雾,他最短的飞行时间及飞行路径。注意:当两个城市间不可达时,消耗时间默认取1000.各城市简的飞行时间如下表所示,加

2017-04-23 19:27:35 1785 4

原创 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: Given binary

2017-04-22 14:53:51 297

原创 symmetric-tree

题目描述Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3But the follo

2017-04-20 12:10:41 233

原创 two-sum

题目描述Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, wh

2017-04-19 21:10:36 225

原创 decode-ways

题目描述A message containing letters fromA-Zis being encoded to numbers using the following mapping: ‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Given an encoded message containing digits, determine the total numbe

2017-04-19 19:47:03 391

原创 restore-ip-addresses

Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example: Given”25525511135”, return[“255.255.11.135”, “255.255.111.35”]. (Order does no

2017-04-19 17:47:38 332

原创 convert-sorted-list-to-binary-search-tree

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNo

2017-04-19 12:55:44 439

原创 container-with-most-water

Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lin

2017-04-19 11:03:49 266

原创 palindrome-number

Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converting the

2017-04-19 10:39:23 292

原创 path-sum-i&ii

题目描述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 andsum = 22, 5 / \

2017-04-18 23:34:20 239

原创 distinct-subsequences

Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is formed from the original string by deleting some (can be none)

2017-04-18 23:14:34 340

原创 populating-next-right-pointers-in-each-node

题目描述Follow up for problem “Populating Next Right Pointers in Each Node”. What if the given tree could be any binary tree? Would your previous solution still work? Note: You may only use constant ext

2017-04-18 21:11:16 333

原创 pascals-triangle-i &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?class Solution {publi

2017-04-18 17:28:37 278

原创 triangle

题目描述Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [2], [3,4],

2017-04-18 16:39:35 285

原创 best-time-to-buy-and-sell-stock i &ii

Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), de

2017-04-18 15:50:57 271

原创 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 / \ 2 3Return6.包含某一节点的最小路径和分为以下

2017-04-18 10:53:48 377

原创 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 a palin

2017-04-17 21:00:07 191

原创 word-ladder

Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: Only one letter can be changed at a time Each intermediate word mu

2017-04-17 19:56:05 394

原创 surrounded-regions

Given a 2D board containing’X’and’O’, capture all regions surrounded by’X’. A region is captured by flipping all’O’s into’X’s in that surrounded region . For example, X X X X X O O X X X O X X O

2017-04-17 17:37:30 264

空空如也

空空如也

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

TA关注的人

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