自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

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

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

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

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

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

原创 华为fx测试题

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

2017-04-23 19:27:35 1788 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 227

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

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

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

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

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

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

原创 palindrome-partitioning

Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s =”aab”, Return [ [“aa”,”b”],

2017-04-17 15:51:18 269

原创 palindrome-partitioning-ii

Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s =”aab”, Return1since

2017-04-17 00:09:48 479

原创 longest-consecutive-sequence

Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given[100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is[1, 2, 3, 4].

2017-04-14 22:09:30 192

原创 sum-root-to-leaf-numbers

题目描述Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number. An example is the root-to-leaf path1->2->3which represents the number123. Find the total sum of

2017-04-14 20:49:11 242

原创 gas-station

There are N gas stations along a circular route, where the amount of gas at station i isgas[i]. You have a car with an unlimited gas tank and it costscost[i]of gas to travel from station i to its next

2017-04-14 10:21:48 278

原创 微软2017 第四题

变种版背包问题: 可以这么理解 父节点背包总重cap,每个子节点拥有重量为Wi,价值为Vi的石头,问将背包填满的最小价值. 解决上述问题,再利用递归就可以求出最小的花费:求上述问题的思路: 设子节点所有的石头重量和为sum,子节点的个数为count; 申请dp[count][sum+1]的数组,dp[i][j]表示用0-i的石头填满j的最小花费.不能填满的花费为-1; 所以dp[0][0]

2017-04-08 22:33:27 315

原创 candy

There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following requirements: Each child must have at least one can

2017-04-03 17:29:09 490

原创 unique-path

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 point in time. The robot is trying to reach the bot

2017-04-03 15:17:17 349

原创 reverse-integer

题目描述 Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Here are some good questions to ask before co

2017-04-03 14:56:36 223

原创 word-break

Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s =”leetcode”, dict =[“leet”, “co

2017-04-02 22:05:46 208

空空如也

空空如也

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

TA关注的人

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