题目如下: We are given hours, a list of the number of hours worked per day for a given employee. A day is considered to be a tiring day if and only if the number of hours worked is (strictly) greater than 8. A well-performing interval is an interval of d…
[LeetCode]522. Longest Uncommon Subsequence II 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/longest-uncommon-subsequence-ii/description/ 题目描述: Given a list of strings, you…
Difficulty: Hard  More:[目录]LeetCode Java实现 Description Given a string S, find the length of the longest substring T that contains at most two distinct characters.For example,Given S = “eceba”,T is "ece" which its length is 3. Intuition 方法一:假设有一个…
Given an unsorted array of integers, find the length of longest increasing subsequence. For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest increasing subsequence is [2, 3, 7, 101], therefore the length is 4. Note that there may be more than…
题目如下: Given a string that consists of only uppercase English letters, you can replace any letter in the string with another letter at most k times. Find the length of a longest substring containing all repeating letters you can get after performing t…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:字典统计次数 方法二:HashSet 方法三:次数除以2再乘以2 日期 [LeetCode] 题目地址:https://leetcode.com/problems/longest-palindrome/ Difficulty: Easy 题目描述 Given a string which consists of lowercase or up…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 双数组 参考资料 日期 题目地址:https://leetcode.com/problems/longest-mountain-in-array/description/ 题目描述 Let's call any (contiguous) subarray B (of A) a mountain if the following properties…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 暴力查找 排序 日期 题目地址:https://leetcode.com/problems/longest-word-in-dictionary/description/ 题目描述 Given a list of strings words representing an English Dictionary, find the longest wo…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 个人公众号:负雪明烛 本文关键词:prefix, 公共前缀,题解,leetcode, 力扣,Python, C++, Java 目录 题目描述 题目大意 解题方法 遍历前缀子串 使用set 遍历最短字符串 排序 日期 题目地址:https://leetcode.com/problems/longest-common-prefix/description/ 题目描述 Write a fun…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 统计次数 日期 题目地址:https://leetcode.com/problems/longest-harmonious-subsequence/description/ 题目描述 We define a harmonious array is an array where the difference between its maximum va…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 动态规划 空间压缩DP 日期 题目地址:https://leetcode.com/problems/longest-continuous-increasing-subsequence/description/ 题目描述 Given an unsorted array of integers, find the length of longest co…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 DFS 日期 题目地址:https://leetcode.com/problems/longest-univalue-path/description/ 题目描述 Given a binary tree, find the length of the longest path where each node in the path has the s…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/longest-increasing-path-in-a-matrix/description/ 题目描述: Given an integer matrix, find the length of the longest increasing path. From each cell, you can either…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/description/ 题目描述: Find the length of the longest substring T of a given string (consists of lowercase…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述: 题目大意 解题方法 日期 题目地址:https://leetcode.com/problems/longest-absolute-file-path/description/ 题目描述: Suppose we abstract our file system by a string in the following manner: The string "dir\n\…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.com/problems/longest-uncommon-subsequence-i/description/ 题目描述 Given a group of two strings, you need to find the longest uncommon subsequence of this g…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 公众号:负雪明烛 本文关键词:无重复字符,最长子串,题解,leetcode, 力扣,python, c++, java 目录 题目描述 题目大意 解题方法 解法一:虫取法+set 方法二:一次遍历+字典 日期 题目地址:https://leetcode.com/problems/longest-substring-without-repeating-characters/descrip…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 公众号:负雪明烛 本文关键词:最长回文子串,题解,leetcode, 力扣,python, C++, java 目录 题目描述 题目大意 解题方法 暴力遍历 动态规划 日期 题目地址:https://leetcode.com/problems/longest-palindromic-substring/description/ 题目描述 Given a string s, find t…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题思路 代码 刷题心得 日期 题目地址:https://leetcode.com/problems/longest-palindromic-subsequence/description/ 题目描述 Given a string s, find the longest palindromic subsequence's length in s. You ma…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.com/problems/longest-increasing-subsequence/description/ 题目描述 Given an unsorted array of integers, find the length of longest increasing subsequence. E…
题目: Write a function to find the longest common prefix string amongst an array of strings. 思路:求最长前缀子串,假设第一个字符串是最长前缀子串,采用增强for得到数组中每个字符串,分别与第一个字符串的同一位置进行比较,有一个字符串在该位置不一致,就返回. public class Solution { public String longestCommonPrefix(String[] strs) { i…
题目: Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 思路:用Manacher算法得到最大回文子串的长度,得到带#的最大回文子串,用split剔除#后转化成String形式输出即可. public…
题目: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", with the length of…
Write a function to find the longest common prefix string amongst an array of strings. Solution: class Solution { public: string longestCommonPrefix(vector<string>& strs) { //runtime:4ms string str=""; if(strs.empty())return str; ; whi…
题目描述: Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 解题分析: 之前百度实习生面试也被问到这个问题.这个题比较简单.就是在分别考虑对称字符字串为奇数和偶数的情况,在不超过字符串范围的情况下向…
Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", with the length of 1.…
problem 409. Longest Palindrome solution1: class Solution { public: int longestPalindrome(string s) { map<char, int> temp; for(auto it:s) temp[it]++; , odd = , mid=false; for(auto it=temp.begin(); it!=temp.end(); ++it) { ==) even+=it->second; els…
Longest Substring Without Repeating Characters Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the lengt…
Longest Valid Parentheses Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the longest valid parentheses substring is "()", which has length…
Longest Consecutive Sequence Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4.…