08 2016 档案

摘要:Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of conference room 阅读全文
posted @ 2016-08-31 13:08 fenshen371 阅读(1207) 评论(0) 推荐(0)
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib 阅读全文
posted @ 2016-08-31 09:00 fenshen371 阅读(158) 评论(0) 推荐(0)
摘要:Given a binary tree, find the length of the longest consecutive sequence path. The path refers to any sequence of nodes from some starting node to any 阅读全文
posted @ 2016-08-31 08:07 fenshen371 阅读(193) 评论(0) 推荐(0)
摘要:Given n points on a 2D plane, find if there is such a line parallel to y-axis that reflect the given points. Example 1: Given points = [[1,1],[-1,1]], 阅读全文
posted @ 2016-08-30 11:50 fenshen371 阅读(159) 评论(0) 推荐(0)
摘要:For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible roote 阅读全文
posted @ 2016-08-29 12:45 fenshen371 阅读(111) 评论(0) 推荐(0)
摘要:Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges mak 阅读全文
posted @ 2016-08-29 11:57 fenshen371 阅读(248) 评论(0) 推荐(0)
摘要:Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return the maximum enemies you can kill using one bomb.T 阅读全文
posted @ 2016-08-29 08:46 fenshen371 阅读(518) 评论(0) 推荐(0)
摘要:You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element from th 阅读全文
posted @ 2016-08-29 07:53 fenshen371 阅读(161) 评论(0) 推荐(0)
摘要:You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take tu 阅读全文
posted @ 2016-08-29 07:00 fenshen371 阅读(284) 评论(0) 推荐(0)
摘要:Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at 阅读全文
posted @ 2016-08-29 05:04 fenshen371 阅读(187) 评论(0) 推荐(0)
摘要:Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list 阅读全文
posted @ 2016-08-28 13:27 fenshen371 阅读(194) 评论(0) 推荐(0)
摘要:Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. 阅读全文
posted @ 2016-08-28 07:10 fenshen371 阅读(184) 评论(0) 推荐(0)
摘要:Given an array of n integers nums and a target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition nums[i] + 阅读全文
posted @ 2016-08-28 06:40 fenshen371 阅读(130) 评论(0) 推荐(0)
摘要:Given a non-negative number represented as a singly linked list of digits, plus one to the number. The digits are stored such that the most significan 阅读全文
posted @ 2016-08-27 13:03 fenshen371 阅读(129) 评论(0) 推荐(0)
摘要:One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, 阅读全文
posted @ 2016-08-27 12:55 fenshen371 阅读(160) 评论(0) 推荐(0)
摘要:Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirected graph serialization: Nodes are labeled 阅读全文
posted @ 2016-08-27 09:35 fenshen371 阅读(120) 评论(0) 推荐(0)
摘要:Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or 阅读全文
posted @ 2016-08-27 09:08 fenshen371 阅读(148) 评论(0) 推荐(0)
摘要:Implement pow(x, n). 思路:n为0时返回1。 之后我们只考虑n为正的情况(n为负时结果为正时的倒数)。之后我们通过二分法来求值。 假如n为偶数,则pow(x, n) = pow(x, n / 2) * pow(x, n / 2)。 假如n为奇数,则pow(x, n) = pow( 阅读全文
posted @ 2016-08-26 06:59 fenshen371 阅读(158) 评论(0) 推荐(0)
摘要:Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: The director 阅读全文
posted @ 2016-08-26 06:20 fenshen371 阅读(329) 评论(2) 推荐(0)
摘要:Implement an iterator to flatten a 2d vector. For example,Given 2d vector = By calling next repeatedly until hasNext returns false, the order of eleme 阅读全文
posted @ 2016-08-25 12:55 fenshen371 阅读(158) 评论(0) 推荐(0)
摘要:Given a sorted array of integers nums and integer values a, b and c. Apply a function of the form f(x) = ax2 + bx + c to each element x in the array. 阅读全文
posted @ 2016-08-25 12:37 fenshen371 阅读(152) 评论(0) 推荐(0)
摘要:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating 阅读全文
posted @ 2016-08-25 11:51 fenshen371 阅读(148) 评论(0) 推荐(0)
摘要:We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wron 阅读全文
posted @ 2016-08-25 11:15 fenshen371 阅读(173) 评论(0) 推荐(0)
摘要:Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column). If two nodes are in the sam 阅读全文
posted @ 2016-08-24 09:41 fenshen371 阅读(142) 评论(0) 推荐(0)
摘要:A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Find all strobogrammatic numbers that are o 阅读全文
posted @ 2016-08-24 06:51 fenshen371 阅读(193) 评论(0) 推荐(0)
摘要:Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen. Follow up:Wha 阅读全文
posted @ 2016-08-23 12:36 fenshen371 阅读(202) 评论(0) 推荐(0)
摘要:You are given a m x n 2D grid initialized with these three possible values. Fill each empty room with the distance to its nearest gate. If it is impos 阅读全文
posted @ 2016-08-23 11:05 fenshen371 阅读(147) 评论(0) 推荐(0)
摘要:Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, ex 阅读全文
posted @ 2016-08-20 02:45 fenshen371 阅读(143) 评论(0) 推荐(0)
摘要:Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10^n. Example:Given n = 2, return 91. (The answer should be the 阅读全文
posted @ 2016-08-19 12:51 fenshen371 阅读(167) 评论(0) 推荐(0)
摘要:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example,Given the following matrix: You s 阅读全文
posted @ 2016-08-19 12:27 fenshen371 阅读(147) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2016-08-19 11:38 fenshen371 阅读(166) 评论(0) 推荐(0)
摘要:Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix. Note that it is th 阅读全文
posted @ 2016-08-19 08:33 fenshen371 阅读(159) 评论(0) 推荐(0)
摘要:Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected 阅读全文
posted @ 2016-08-19 07:11 fenshen371 阅读(159) 评论(0) 推荐(0)
摘要:Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes  阅读全文
posted @ 2016-08-18 11:30 fenshen371 阅读(209) 评论(0) 推荐(0)
摘要:Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 阅读全文
posted @ 2016-08-18 11:11 fenshen371 阅读(165) 评论(0) 推荐(0)
摘要:Given a sorted integer array where the range of elements are [lower, upper] inclusive, return its missing ranges. For example, given [0, 1, 3, 50, 75] 阅读全文
posted @ 2016-08-17 11:10 fenshen371 阅读(129) 评论(0) 推荐(0)
摘要:You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smal 阅读全文
posted @ 2016-08-17 08:56 fenshen371 阅读(242) 评论(0) 推荐(0)
摘要:Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target. Note: Given target value is a floati 阅读全文
posted @ 2016-08-15 02:54 fenshen371 阅读(164) 评论(0) 推荐(0)
摘要:Given a string, determine if a permutation of the string could form a palindrome. For example,"code" -> False, "aab" -> True, "carerac" -> True. 要点:学习 阅读全文
posted @ 2016-08-15 02:39 fenshen371 阅读(152) 评论(0) 推荐(0)
摘要:Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is not printed in t 阅读全文
posted @ 2016-08-15 02:28 fenshen371 阅读(175) 评论(0) 推荐(0)
摘要:You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take tu 阅读全文
posted @ 2016-08-14 12:26 fenshen371 阅读(136) 评论(0) 推荐(0)
摘要:Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequen 阅读全文
posted @ 2016-08-14 12:18 fenshen371 阅读(129) 评论(0) 推荐(0)
摘要:Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index. According 阅读全文
posted @ 2016-08-14 02:36 fenshen371 阅读(129) 评论(0) 推荐(0)
摘要:There is a fence with n posts, each post can be painted with one of the k colors. You have to paint all the posts such that no more than two adjacent 阅读全文
posted @ 2016-08-13 12:31 fenshen371 阅读(204) 评论(0) 推荐(0)
摘要:An abbreviation of a word follows the form <first letter><number><last letter>. Below are some examples of word abbreviations: a) it --> it (no abbrev 阅读全文
posted @ 2016-08-13 12:02 fenshen371 阅读(209) 评论(0) 推荐(0)
摘要:Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. For example, 阅读全文
posted @ 2016-08-13 10:56 fenshen371 阅读(141) 评论(0) 推荐(0)
摘要:A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to determine if a number i 阅读全文
posted @ 2016-08-13 10:40 fenshen371 阅读(129) 评论(0) 推荐(0)
摘要:We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wron 阅读全文
posted @ 2016-08-13 10:18 fenshen371 阅读(141) 评论(0) 推荐(0)