- 博客(21)
- 收藏
- 关注
原创 算法概论 8.3题
Problem: STINGY SAT is the following problem : given a set of clauses (each a disjunction of literals) and an integer k , find a satisfying assignment in which at most k variables are true , if su
2017-07-14 12:21:51
258
1
原创 Largest Divisible Subset
Description 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 Sj % Si = 0.If there are multiple solu
2017-06-20 11:32:15
245
原创 Unique Paths II
Desctiption 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 is marked as 1 and 0 respectively i
2017-06-12 19:05:20
355
原创 Burst Balloons
Description Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will
2017-06-04 21:26:52
255
1
原创 Unique Binary Search Trees II
Description 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 return all 5 unique BST’s shown below.
2017-05-30 16:06:28
185
原创 Arithmetic Slices
Description A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic
2017-05-21 23:22:03
220
原创 Unique Paths
Description 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 re
2017-05-09 23:00:43
147
原创 Guess Number Higher or Lower II
Description 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 wrong, I’ll tell you whether the
2017-05-08 20:07:54
198
原创 Predict the Winner
Description Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a pl
2017-05-01 00:45:33
196
原创 Best Time to Buy and Sell Stock II
Description 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 complete as many transactions as you li
2017-04-23 15:59:10
224
原创 Reconstruct Itinerary
Description Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from J
2017-04-14 20:57:46
611
1
原创 Evaluate Division
Description Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If
2017-04-09 18:29:09
241
1
原创 01 Matrix
Description Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.The distance between two adjacent cells is 1. Example 1: Input:0 0 0 0 1 0 0 0 0 Output: 0 0 0
2017-04-08 21:34:18
300
原创 Perfect Squares
Description Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n. For example, given n = 12, return 3 because 12 = 4 + 4 + 4; gi
2017-04-01 19:59:11
452
原创 Minesweeper
Description You are given a 2D char matrix representing the game board. ‘M’ represents an unrevealed mine, ‘E’ represents an unrevealed empty square, ‘B’ represents a revealed blank square that has no
2017-03-31 18:30:22
215
原创 Target Sum
Descpition: You are given a list of non-negative integers, a1, a2, …, an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.Find o
2017-03-24 18:19:45
188
原创 Convert Sorted Array to Binary Search Tree
Description Given an array where elements are sorted in ascending order, convert it to a height balanced BST.解题思路: 给定一个元素递增的数组,构造一棵平衡的二叉搜索树。既然数组已经有序,而且是平衡的二叉搜索树,所以我想到的便是一开始取数组的中间元素作为根节点,用中间元素左
2017-03-19 17:15:56
284
原创 Binary Tree Paths
DescriptionGiven a binary tree, return all root-to-leaf paths. For example, given the following binary tree:1 / \ 2 3 \ 5 All root-to-leaf paths are:[“1->2->5”, “1->3”]解题思路:题目要求找出从根节点到所
2017-03-19 16:50:52
178
原创 Kth Largest Element in an Array
Description 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, re
2017-03-05 17:08:32
238
原创 Different Ways to Add Parentheses
Description Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *.Examp
2017-03-04 22:20:57
190
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人