自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 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 complete at most two transactions.Note: You may not eng...

2020-02-12 17:27:56 137

原创 LeetCode-Best Time to Buy and Sell Stock IV(JAVA)

Say you have an array for which the i-th element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most k transactions.Note:You may not enga...

2020-02-12 17:22:14 147

原创 LeetCode-Distinct Subsequences(JAVA)

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 (can...

2020-02-10 22:02:25 121

原创 LeetCode-Interleaving String(JAVA)

Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = “great”:great/ gr eat/ \ ...

2020-02-10 00:27:14 112

原创 LeetCode-Scramble String(JAVA)

Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = “great”:great/ gr eat/ \ ...

2020-02-10 00:24:40 121

原创 LeetCode-Maximal Rectangle(JAVa)

Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area.说明:参考LeetCode-Largest Rectangle in Histogram(JAVA)针对二维数组的每一行,生成直方图,求出该直方图中的最大矩形。...

2020-02-09 21:25:49 276

原创 LeetCode-Largest Rectangle in Histogram(JAVA)

Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.class Solution { public int largestRec...

2020-02-09 21:22:19 291

原创 LeetCode-Wildcard Matching (JAVA)

Given an input string (s) and a pattern §, implement wildcard pattern matching with support for ‘?’ and ‘*’.‘?’ Matches any single character.‘*’ Matches any sequence of characters (including the emp...

2020-02-08 17:50:56 104

原创 LeetCode- Longest Valid Parentheses(JAVA)

Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.Example 1:Input: “(()”Output: 2Explanation: The longest valid pa...

2020-02-08 17:13:26 123

原创 Leetcode-Regular Expression Matching(JAVA)

Given an input string (s) and a pattern §, implement regular expression matching with support for ‘.’ and ‘*’.‘.’ Matches any single character.‘*’ Matches zero or more of the preceding element.The ...

2020-02-07 20:30:22 148

原创 LeetCode-Maximal Square(JAVA)

Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area.Example:Input:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0Output: 4求在0和1组成的数组中,由1填充组成的...

2020-02-05 22:03:16 136

原创 LeetCode-Maximum Product Subarray(JAVA)

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] Output: 6 Explanation: [2,3] has...

2020-02-02 17:32:16 130

原创 LeetCode-Word Break(JAVA)

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 sequence of one or more dictionary words.Note:The sa...

2020-02-02 17:23:11 102

原创 LeetCode-Unique Binary Search Trees II(JAVA)

Given an integer n, generate all structurally unique BST’s (binary search trees) that store values 1 … n.Example:Input: 3Output:[ [1,null,3,2], [3,2,null,1], [3,1,null,null,2], [2,1,3], ...

2020-02-02 17:05:18 136

原创 LeetCode-Unique Binary Search Trees(JAVA)

Given n, how many structurally unique BST’s (binary search trees) that store values 1 … n?Example:Input: 3 Output: 5 Explanation: Given n = 3, there are a total of 5unique BST’s:1 3 3...

2020-02-02 16:38:09 165

原创 LeetCode-Longest Palindromic Substring(JAVA)

Given a string s, find the longest palindromic substring in s. You mayassume that the maximum length of s is 1000.Example 1:Input: “babad” Output: “bab” Note: “aba” is also a valid answer.Example...

2019-12-25 21:23:29 97

原创 LeetCode-Edit Distance(JAVA)

Given two words word1 and word2, find the minimum number of operationsrequired to convert word1 to word2.You have the following 3 operations permitted on a word:Insert a character Delete a charact...

2019-12-25 21:13:54 93

原创 LeetCode-Majority Element II (JAVA)

Given an integer array of size n, find all elements that appear morethan ⌊ n/3 ⌋ times.Note: The algorithm should run in linear time and in O(1) space.Example 1:Input: [3,2,3] Output: [3] Example...

2019-12-24 22:23:57 110

原创 LeetCode-Combination Sum II (JAVA)

Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.Each number in candidates may...

2019-12-20 19:59:10 118

原创 LeetCode-combination-sum (JAVA)

Given a set of candidate numbers (candidates) (without duplicates) anda target number (target), find all unique combinations in candidateswhere the candidate numbers sums to target.The same repeat...

2019-12-20 19:40:14 96

原创 LeetCode- Find First and Last Position of Element in Sorted Array (JAVA)

Given an array of integers nums sorted in ascending order, find thestarting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If the ...

2019-12-19 18:08:50 119

原创 LeetCod-Search in Rotated Sorted Array (Java)

Suppose an array sorted in ascending order is rotated at some pivotunknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).You are given a target value to search. If found i...

2019-12-19 17:58:24 104

原创 LEET CODE-Next Permutation(JAVA)

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible o...

2019-12-19 17:06:36 92

原创 kafka-cosumer阻塞消费

kafka中consumer对于消息的消费是阻塞的。ConsumerConnector connector;Map<String, Integer> topiccont;......Map<String,List<KafkaStream<String, String>>> streams = connector.creatMessageStreams(topiccont);/**for(K

2017-02-17 13:36:17 4812

原创 FileZilla-FTP下载失败

FileZilla上传成功,但是下载失败。 发现是保存地址的问题。直接保存在C盘失败,报错如下: 错误: 打开“C:\test.txt”写入失败 错误: 文件传输失败 状态: 开始下载 /测试地址/test.txt 错误: 打开“C:\test.txt”写入失败 错误: 文件传输失败 状态: 开始下载 /测试地址/test.txt 错误: 打开“C:\test.txt”写入失败 错

2017-02-15 17:36:04 3838

原创 LeetCode-Add and Search Word - Data structure design(C++)

Design a data structure that supports the following two operations:void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only letters a

2015-07-18 21:22:24 386

原创 Leetcode-Implement Queue using Stacks(C++)

Implement the following operations of a queue using stacks.push(x) – Push element x to the back of queue. pop() – Removes the element from in front of queue. peek() – Get the front element. empty()

2015-07-18 20:24:38 479

原创 Leetcode-Implement Stack using Queues(C++)

Implement the following operations of a stack using queues.push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the top element. empty() – Return whether

2015-07-18 20:19:12 324

原创 Leetcode-Min Stack(C++)

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the

2015-07-18 20:13:35 308

原创 LeetCode-Implement Trie (Prefix Tree) (C++)

Implement a trie with insert, search, and startsWith methods.Note: You may assume that all inputs are consist of lowercase letters a-z. 题意:实现一个字典树(前缀树),包含查找、插入功能。 参考文章:字典树(Prefix Tree)注意:查找一个word是否在

2015-07-18 20:09:49 663

原创 Leetcode-Sudoku Solver

Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character ‘.’.You may assume that there will be only one unique solution. 题意:将一个数独补充完整。 解题思路:从第一个空

2015-07-14 20:28:59 302

原创 Leetcode-N-Queens II

Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.题意:对于一个n皇后问题,返回解的个数 解题思路:基于N-Queens,这个II版的反而更简单,记录解的个数并返回即可。bool iv(vector<in

2015-07-14 19:18:33 361

原创 Leetcode-N-Queens

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle.Each solut

2015-07-14 19:14:21 341

原创 Leetcode-Permutations II

Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1], and [2,1,1]. 题意:对一

2015-07-14 19:07:31 264

原创 LeetCode-Permutations

Given a collection of numbers, return all possible permutations.For example, [1,2,3] have the following permutations: [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]. 题意:求出一组数的全排 解题思路:对数字按

2015-07-14 19:02:20 315

原创 Leetcode-Regular Expression Matching(C++)

Implement regular expression matching with support for ‘.’ and ‘*’.‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element.The matching should cover the entire input string

2015-07-07 13:04:54 394

原创 Leetcode-Word Break II

Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, given s = “catsanddo

2015-07-06 17:26:40 371

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

2015-07-06 17:18:52 285

原创 LeetCode-ZigZag Conversion

The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H N A P L S I I G

2015-06-29 22:21:14 358

原创 LeetCode-Valid Number

Validate if a given string is numeric.Some examples: “0” => true ” 0.1 ” => true “abc” => false “1 a” => false “2e10” => true Note: It is intended for the problem statement to be ambiguous. You s

2015-06-29 11:15:25 244

空空如也

空空如也

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

TA关注的人

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