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

2018年11月6日

309. Best Time to Buy and Sell Stock with Cooldown

摘要: 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 (ie, buy one ... 阅读全文

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

188. Best Time to Buy and Sell Stock IV

摘要: 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:42 猪猪🐷 阅读(82) 评论(0) 推荐(0)

714. Best Time to Buy and Sell Stock with Transaction Fee

摘要: Your are given an array of integers prices, for which the i-th element is the price of a given stock on day i; and a non-negative integer fee representing a transaction fee. You may complete as many ... 阅读全文

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

140 Word Break II

摘要: Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible... 阅读全文

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

139 Word Break

摘要: Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequ 阅读全文

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

91. Decode Ways

摘要: A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given a non-empty string containing only digits, determine the total num... 阅读全文

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

279. Perfect Squares

摘要: Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Example 1: Input: n = 12 Output: 3 Explanation: 12 = 4 + 4 + 4. Example 2:... 阅读全文

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

131. Palindrome Partitioning

摘要: dfs dfs + preprocessing 阅读全文

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

472. Concatenated Words

摘要: Given a list of words (without duplicates), please write a program that returns all concatenated words in the given list of words. A concatenated word is defined as a string that is comprised entirel... 阅读全文

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

45. Jump Game II

摘要: 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. Your goal is to ... 阅读全文

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

674 Longest Continuous Increasing Subsequence

摘要: Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray). Example 1: Input: [1,3,5,4,7] Output: 3 Explanation: The longest continuous increasing s... 阅读全文

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

300. Longest Increasing Subsequence

摘要: Smallest larger than 4 is 5 1 3 5 7 4 1 3 4 7 这道题,遇到新的数, 如果新的数比队尾的数还要大, 那么就把新的数加到队尾, 如果新的数等于或者小于队尾的数, 那么就在队列中找到比第一个比新的数大的最小的数, smallest larger , 这里用到了 阅读全文

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

2018年10月9日

723. Candy Crush

摘要: 723. Candy Crush This question is about implementing a basic elimination algorithm for Candy Crush. Given a 2D integer array board representing the grid of candy, different positive integers board[i]... 阅读全文

posted @ 2018-10-09 02:58 猪猪🐷 阅读(301) 评论(0) 推荐(0)

353. Design Snake Game

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

posted @ 2018-10-09 02:56 猪猪🐷 阅读(147) 评论(0) 推荐(0)

2018年10月3日

Given a matrix, get the number of path from the top left cell to the top right cell.

摘要: Given a matrix, get the number of path from the top left cell to the top right cell. Note that: you can only go right, up right, down right. (0,0) (0, 阅读全文

posted @ 2018-10-03 23:55 猪猪🐷 阅读(127) 评论(0) 推荐(0)

2018年9月25日

855. Exam Room

摘要: In an exam room, there are N seats in a single row, numbered 0, 1, 2, ..., N-1. When a student enters the room, they must sit in the seat that maximizes the distance to the closest person. If there ... 阅读全文

posted @ 2018-09-25 04:25 猪猪🐷 阅读(297) 评论(0) 推荐(0)

774. Minimize Max Distance to Gas Station

摘要: On a horizontal number line, we have gas stations at positions stations[0], stations[1], ..., stations[N-1], where N = stations.length. Now, we add K more gas stations so that D, the maximum distanc... 阅读全文

posted @ 2018-09-25 04:23 猪猪🐷 阅读(158) 评论(0) 推荐(0)

568. Maximum Vacation Days

摘要: LeetCode wants to give one of its best employees the option to travel among N cities to collect algorithm problems. But all work and no play makes Jack a dull boy, you could take vacations in some pa... 阅读全文

posted @ 2018-09-25 04:21 猪猪🐷 阅读(128) 评论(0) 推荐(0)

529. Minesweeper

摘要: Example 2: 阅读全文

posted @ 2018-09-25 04:18 猪猪🐷 阅读(146) 评论(0) 推荐(0)

2018年9月20日

844. Backspace String Compare

摘要: Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. Example 1: Input: S = "ab#c", T = "ad#c" Output: true Explanation: Both... 阅读全文

posted @ 2018-09-20 18:31 猪猪🐷 阅读(129) 评论(0) 推荐(0)

734. Sentence Similarity

摘要: Given two sentences words1, words2 (each represented as an array of strings), and a list of similar word pairs pairs, determine if two sentences are similar. For example, "great acting skills" and "f... 阅读全文

posted @ 2018-09-20 18:30 猪猪🐷 阅读(164) 评论(0) 推荐(0)

729. My Calendar I

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

posted @ 2018-09-20 18:27 猪猪🐷 阅读(151) 评论(0) 推荐(0)

737. Sentence Similarity II

摘要: 737. Sentence Similarity II Given two sentences words1, words2 (each represented as an array of strings), and a list of similar word pairs pairs, determine if two sentences are similar. For example... 阅读全文

posted @ 2018-09-20 18:26 猪猪🐷 阅读(161) 评论(0) 推荐(0)

760. Find Anagram Mappings

摘要: 760. Find Anagram Mappings Given two lists Aand B, and B is an anagram of A. B is an anagram of A means B is made by randomizing the order of the elements in A. We want to find an index mapping P, ... 阅读全文

posted @ 2018-09-20 18:25 猪猪🐷 阅读(105) 评论(0) 推荐(0)

130. Surrounded Regions

摘要: Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region. Example: X X X X X O O X ... 阅读全文

posted @ 2018-09-20 18:23 猪猪🐷 阅读(101) 评论(0) 推荐(0)

766. Toeplitz Matrix

摘要: 1. 这个带返回值的recursion, 2. 如果out of bound, return true, 说明走到头了 阅读全文

posted @ 2018-09-20 18:22 猪猪🐷 阅读(82) 评论(0) 推荐(0)

62. Unique Paths

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

posted @ 2018-09-20 18:21 猪猪🐷 阅读(85) 评论(0) 推荐(0)

7. Reverse Integer

摘要: Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 class Solution { public i... 阅读全文

posted @ 2018-09-20 18:20 猪猪🐷 阅读(63) 评论(0) 推荐(0)

84. Largest Rectangle in Histogram

摘要: 84. Largest Rectangle in Histogram https://www.youtube.com/watch?v=KkJrGxuQtYo&t=129s https://leetcode.com/problems/largest-rectangle-in-histogram/solution/ https://www.cnblogs.com/boring09/p/42... 阅读全文

posted @ 2018-09-20 18:18 猪猪🐷 阅读(133) 评论(0) 推荐(0)

64. Minimum Path Sum

摘要: https://leetcode.com/problems/minimum-path-sum/solution/ Approach 3: Dynamic Programming 1D Approach 4: Dynamic Programming (Without Extra Space) 阅读全文

posted @ 2018-09-20 18:17 猪猪🐷 阅读(86) 评论(0) 推荐(0)

50. Pow(x, n)

摘要: Implement pow(x, n), which calculates x raised to the power n (xn). Example 1: Input: 2.00000, 10 Output: 1024.00000 Example 2: Input: 2.10000, 3 Output: 9.26100 Example 3: Input: 2.00000, -2 Output:... 阅读全文

posted @ 2018-09-20 18:16 猪猪🐷 阅读(96) 评论(0) 推荐(0)

329. Longest Increasing Path in a Matrix

摘要: Given an integer matrix, find the length of the longest increasing path. From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside o... 阅读全文

posted @ 2018-09-20 18:15 猪猪🐷 阅读(101) 评论(0) 推荐(0)

394. Decode String

摘要: 394. Decode String Two solutions: solution 1 : Recursion , solution 2 : Iterative with stack to imitate the call stack used in recursion http://www.cnblogs.com/grandyang/p/5849037.html publ... 阅读全文

posted @ 2018-09-20 18:14 猪猪🐷 阅读(88) 评论(0) 推荐(0)

343. Integer Break

摘要: 343. Integer Break Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get. Example 1: ... 阅读全文

posted @ 2018-09-20 18:11 猪猪🐷 阅读(68) 评论(0) 推荐(0)

198. House Robber

摘要: 198. House Robber You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is... 阅读全文

posted @ 2018-09-20 18:09 猪猪🐷 阅读(79) 评论(0) 推荐(0)

485. Max Consecutive Ones

摘要: 485. Max Consecutive Ones Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last thre... 阅读全文

posted @ 2018-09-20 18:09 猪猪🐷 阅读(78) 评论(0) 推荐(0)

646. Maximum Length of Pair Chain

摘要: 646. Maximum Length of Pair Chain You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can follow another pair (a,... 阅读全文

posted @ 2018-09-20 18:08 猪猪🐷 阅读(98) 评论(0) 推荐(0)

55. Jump Game

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

posted @ 2018-09-20 18:07 猪猪🐷 阅读(238) 评论(0) 推荐(0)

152. Maximum Product Subarray

摘要: 152. Maximum Product Subarray Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. Example 1: Input: [2,3,-2,4] ... 阅读全文

posted @ 2018-09-20 18:06 猪猪🐷 阅读(93) 评论(0) 推荐(0)

merge sort

摘要: merge sort public class MergeSort{ public int[] mergeSort(int[] array){ if(array == null){ return array; } int[] helper = new int[array.length]; mergeSort(array, helpe... 阅读全文

posted @ 2018-09-20 18:05 猪猪🐷 阅读(141) 评论(0) 推荐(0)

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

导航