上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 15 下一页

2018年11月6日

313. Super Ugly Number

摘要: 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 of size k. Example: Input: n = 12, primes = [2,7,... 阅读全文

posted @ 2018-11-06 08:40 猪猪🐷 阅读(94) 评论(0) 推荐(0)

378. Kth Smallest Element in a Sorted Matrix

摘要: 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 the kth smallest element in the sorted order, not t... 阅读全文

posted @ 2018-11-06 08:39 猪猪🐷 阅读(96) 评论(0) 推荐(0)

444. Sequence Reconstruction

摘要: Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. The org sequence is a permutation of the integers from 1 to n, with 1 ≤ n ≤ 104. Reconstruction means... 阅读全文

posted @ 2018-11-06 08:37 猪猪🐷 阅读(156) 评论(0) 推荐(0)

128. Longest Consecutive Sequence

摘要: Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in O(n) complexity. Example: Input: [100, 4, 200, 1, 3, 2] Output: 4 Expla... 阅读全文

posted @ 2018-11-06 08:30 猪猪🐷 阅读(85) 评论(0) 推荐(0)

307. Range Sum Query - Mutable

摘要: Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. The update(i, val) function modifies nums by updating the element at index i to val. Example: ... 阅读全文

posted @ 2018-11-06 08:26 猪猪🐷 阅读(76) 评论(0) 推荐(0)

315. Count of Smaller Numbers After Self

摘要: 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 smaller elements to the right of nums[i]. Example: In... 阅读全文

posted @ 2018-11-06 08:24 猪猪🐷 阅读(77) 评论(0) 推荐(0)

308. Range Sum Query 2D - Mutable

摘要: Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).  The above rectangle (with the red bor... 阅读全文

posted @ 2018-11-06 08:24 猪猪🐷 阅读(90) 评论(0) 推荐(0)

731. My Calendar II

摘要: Implement a MyCalendarTwo class to store your events. A new event can be added if adding the event will not cause a triple booking. Your class will have one method, book(int start, int end). Formally... 阅读全文

posted @ 2018-11-06 08:23 猪猪🐷 阅读(257) 评论(0) 推荐(0)

732. My Calendar III

摘要: Implement a MyCalendarThree class to store your events. A new event can always be added. Your class will have one method, book(int start, int end). Formally, this represents a booking on the half ope... 阅读全文

posted @ 2018-11-06 08:21 猪猪🐷 阅读(140) 评论(0) 推荐(0)

224. Basic Calculator

摘要: Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty sp... 阅读全文

posted @ 2018-11-06 08:20 猪猪🐷 阅读(109) 评论(0) 推荐(0)

227. Basic Calculator II

摘要: http://www.cnblogs.com/grandyang/p/4601208.html Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / operators a... 阅读全文

posted @ 2018-11-06 08:19 猪猪🐷 阅读(237) 评论(0) 推荐(0)

772. Basic Calculator III

摘要: Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty sp... 阅读全文

posted @ 2018-11-06 08:18 猪猪🐷 阅读(268) 评论(0) 推荐(0)

398. Random Pick Index

摘要: Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array. Note:
The array size can ... 阅读全文

posted @ 2018-11-06 08:17 猪猪🐷 阅读(99) 评论(0) 推荐(0)

604. Design Compressed String Iterator

摘要: Design and implement a data structure for a compressed string iterator. It should support the following operations: next and hasNext. The given compressed string will be in the form of each letter fo... 阅读全文

posted @ 2018-11-06 08:16 猪猪🐷 阅读(149) 评论(0) 推荐(0)

173. Binary Search Tree Iterator

摘要: Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the next smallest number in the BST. Note: next() and ... 阅读全文

posted @ 2018-11-06 08:15 猪猪🐷 阅读(73) 评论(0) 推荐(0)

251. Flatten 2D Vector

摘要: 251. Flatten 2D Vector Implement an iterator to flatten a 2d vector. Example: Input: 2d vector = [ [1,2], [3], [4,5,6] ] Output: [1,2,3,4,5,6] Explanation: By calling next repeatedly until has... 阅读全文

posted @ 2018-11-06 08:15 猪猪🐷 阅读(67) 评论(0) 推荐(0)

353. Design Snake Game

摘要: Design a Snake game that is played on a device with screen size = width x height. Play the game online if you are not familiar with the game. The snake is initially positioned at the top left corner ... 阅读全文

posted @ 2018-11-06 08:14 猪猪🐷 阅读(97) 评论(0) 推荐(0)

348. Design Tic-Tac-Toe

摘要: Design a Tic-tac-toe game that is played between two players on a n x n grid. You may assume the following rules: 1. A move is guaranteed to be valid and is placed on an empty block. 2. Once a winnin... 阅读全文

posted @ 2018-11-06 08:13 猪猪🐷 阅读(140) 评论(0) 推荐(0)

588. Design In-Memory File System

摘要: Design an in-memory file system to simulate the following functions: ls: Given a path in string format. If it is a file path, return a list that only 阅读全文

posted @ 2018-11-06 08:12 猪猪🐷 阅读(132) 评论(0) 推荐(0)

363. Max Sum of Rectangle No Larger Than K

摘要: Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is no larger than k. Example: Input: matrix = [[1,0,1],[0,-2,3]], k = 2 Output: 2 ... 阅读全文

posted @ 2018-11-06 08:06 猪猪🐷 阅读(95) 评论(0) 推荐(0)

63. Unique Paths II

摘要: 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 bo... 阅读全文

posted @ 2018-11-06 08:06 猪猪🐷 阅读(95) 评论(0) 推荐(0)

174. Dungeon Game

摘要: The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially po... 阅读全文

posted @ 2018-11-06 08:05 猪猪🐷 阅读(117) 评论(0) 推荐(0)

741. Cherry Pickup

摘要: In a N x N grid representing a field of cherries, each cell is one of three possible integers. 0 means the cell is empty, so you can pass through; 1 means the cell contains a cherry, that you can pi... 阅读全文

posted @ 2018-11-06 08:04 猪猪🐷 阅读(112) 评论(0) 推荐(0)

72. Edit Distance

摘要: Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitted on a word: 1. Insert a character 2. Delete a c... 阅读全文

posted @ 2018-11-06 08:03 猪猪🐷 阅读(79) 评论(0) 推荐(0)

115. Distinct Subsequences

摘要: Given a string S and a string T, count the number of distinct subsequences of S which equals T. A subsequence of a string is a new string which is formed from the original string by deleting some (c... 阅读全文

posted @ 2018-11-06 08:02 猪猪🐷 阅读(83) 评论(0) 推荐(0)

727. Minimum Window Subsequence

摘要: Given strings S and T, find the minimum (contiguous) substring W of S, so that T is a subsequence of W. If there is no such window in S that covers all characters in T, return the empty string "". If... 阅读全文

posted @ 2018-11-06 08:01 猪猪🐷 阅读(100) 评论(0) 推荐(0)

5. Longest Palindromic Substring

摘要: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Example... 阅读全文

posted @ 2018-11-06 08:00 猪猪🐷 阅读(101) 评论(0) 推荐(0)

322. Coin Change

摘要: 322. Coin Change You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of c 阅读全文

posted @ 2018-11-06 07:59 猪猪🐷 阅读(273) 评论(0) 推荐(0)

518. Coin Change 2

摘要: 518. Coin Change 2 You are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may assume that you... 阅读全文

posted @ 2018-11-06 07:58 猪猪🐷 阅读(116) 评论(0) 推荐(0)

494. Target Sum

摘要: 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 o 阅读全文

posted @ 2018-11-06 07:55 猪猪🐷 阅读(65) 评论(0) 推荐(0)

474. Ones and Zeroes

摘要: In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue. For now, suppose you are a dominator of m 0s and n 1s respectively. On the other ... 阅读全文

posted @ 2018-11-06 07:54 猪猪🐷 阅读(115) 评论(0) 推荐(0)

416 Partition Equal Subset Sum

摘要: Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal. Note: 1. Each of the array el... 阅读全文

posted @ 2018-11-06 07:53 猪猪🐷 阅读(119) 评论(0) 推荐(0)

213. House Robber II

摘要: https://www.youtube.com/watch?v=-i2BFAU25Zk You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arrang... 阅读全文

posted @ 2018-11-06 07:51 猪猪🐷 阅读(179) 评论(0) 推荐(0)

276. Paint Fence

摘要: https://www.youtube.com/watch?v=deh7UpSRaEY 阅读全文

posted @ 2018-11-06 07:50 猪猪🐷 阅读(108) 评论(0) 推荐(0)

265. Paint House II

摘要: There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two a... 阅读全文

posted @ 2018-11-06 07:48 猪猪🐷 阅读(123) 评论(0) 推荐(0)

403. Frog Jump

摘要: https://www.youtube.com/watch?v=-FBfrVz841k https://leetcode.com/problems/frog-jump/solution/ A frog is crossing a river. The river is divided into x units and at each unit there may or may not... 阅读全文

posted @ 2018-11-06 07:47 猪猪🐷 阅读(80) 评论(0) 推荐(0)

361. Bomb Enemy

摘要: 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.
The bomb kills all the enemies in the same row an... 阅读全文

posted @ 2018-11-06 07:46 猪猪🐷 阅读(77) 评论(0) 推荐(0)

121. Best Time to Buy and Sell Stock

摘要: 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 (i.e., buy one and sell one share of the stock),... 阅读全文

posted @ 2018-11-06 07:45 猪猪🐷 阅读(83) 评论(0) 推荐(0)

122. Best Time to Buy and Sell Stock II

摘要: 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 like (i.e., buy on... 阅读全文

posted @ 2018-11-06 07:43 猪猪🐷 阅读(91) 评论(0) 推荐(0)

123. Best Time to Buy and Sell Stock III

摘要: 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 @ 2018-11-06 07:43 猪猪🐷 阅读(91) 评论(0) 推荐(0)

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 15 下一页

导航