题目: Given an unsorted array of integers, find the number of longest increasing subsequence. Example 1: Input: [1,3,5,4,7] Output: 2 Explanation: The t ...
分类:
编程语言 时间:
2020-01-17 19:04:48
阅读次数:
77
Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer ...
分类:
其他好文 时间:
2020-01-17 15:08:09
阅读次数:
93
来源 https://leetcode cn.com/problems/longest substring without repeating characters/ 题目描述 给定一个字符串,请你找出其中不含有重复字符的?最长子串?的长度。 示例?1: 输入: "abcabcbb" 输出: 3 解 ...
分类:
编程语言 时间:
2020-01-15 19:47:02
阅读次数:
82
最长的回文子串。题意是给一个字符串,请输出其中最长的回文子串。例子 Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Example 2: Input: "cbbd" Output: "bb" 这个 ...
分类:
其他好文 时间:
2020-01-15 09:23:40
阅读次数:
66
暴力法 public class Solution { public boolean isValid(String s) { Stack<Character> stack = new Stack<Character>(); for (int i = 0; i < s.length(); i++) { ...
分类:
其他好文 时间:
2020-01-14 23:55:09
阅读次数:
146
最长无重复字符的子串。 题意是给一个input字符串,请输出其最长的,没有重复字符的substring。这是two pointer/sliding window的基础题。例子 Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer ...
分类:
其他好文 时间:
2020-01-14 09:18:01
阅读次数:
72
又开始刷题了,去年被这道题虐过,今天终于写了一个还能看的版本。 这个版本肯定不是最优,这篇博客主要记录一下解题的过程,反思如何构思代码。 最长回文子串 来源:力扣(LeetCode) 链接:https://leetcode cn.com/problems/longest palindromic su ...
分类:
编程语言 时间:
2020-01-10 20:38:00
阅读次数:
169
1.暴力法: 本题让求给定字符串的最长的无重复字符的子串,首先想到暴力解法,穷举出字符串的所有子串,并判断每个子串是否是不重复子串,具体使用hashset或set判是否有重复字符;暴力法效率很差,时间O(n^3),空间O(n);参考代码如下: 1 class Solution { 2 public: ...
分类:
其他好文 时间:
2020-01-07 13:27:01
阅读次数:
84
原题链接在这里:https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/ 题目: Find the length of the longest substring T of a give ...
分类:
其他好文 时间:
2020-01-06 15:00:54
阅读次数:
81
如题,我们希望像gdb C程序一样。对python程序就行debug 可以使用pdb来实现这样的功能。 见:https://docs.python.org/3/library/pdb.html 最简单的方法,我们以 longest_substring.py 为例。 使用如下方式执行它,便进入了deb ...
分类:
数据库 时间:
2020-01-06 12:30:20
阅读次数:
100