ICode9

精准搜索请尝试: 精确搜索
  • Leetcode-5058 Longest Duplicate Substring(最长重复子串)2019-05-12 12:48:08

    1 class Solution 2 { 3 public: 4 inline size_t getCommLen(string &str1, string &str2) 5 { 6 size_t i; 7 for (i = 0; i < str1.size() && i < str2.size(); i++) 8 { 9 if (str1[i] != str2[i])10 bre

  • 无重复字符的最长字符串2019-05-05 10:38:40

    题目:https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/ 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 法一: def lengthOfLongestSubstring(s): listi = [] if len(s) in [0,1]: return len(s) else:

  • 无重复字符的最长子串2019-05-03 11:48:04

    //方法一:使用HashMap记录字符的位置,实现滑动窗口 public class LengthOfLongestSubstring {public int lengthOfLonggestSubstring(String s) { if(s == null) { throw new IllegalArgumentException(); }else { Map<Character, Integer> map = new

  • poj32942019-05-03 09:51:43

    这题二分加HASH   6-7秒,如果能用unordered_map,5秒。后缀自动机200-400ms。后缀数组(没写)大概2000ms。 #include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <vector>#include <iomanip>#include <cstring>#include <map

  • leetcode10312019-04-21 12:52:36

    1 class Solution(object): 2 def getMaxByCount(self,A,maxlen): 3 curmax = 0 4 curmax = sum(A[:maxlen]) 5 bigmax = curmax 6 n = len(A) 7 for i in range(maxlen,n): 8 curmax = curmax-A[i-maxlen]+A[i] 9

  • leetcode:[3]最长不含重复字符子串2019-04-19 15:55:52

    Input: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3. Input: "bbbbb"Output: 1Explanation: The answer is "b", with the length of 1. Input: "pwwkew"Output: 3Explanation: The

  • leetcode 32.最长有效括号2019-03-31 12:41:17

    题目: 给定一个只包含 '(' 和 ')' 的字符串,找出最长的包含有效括号的子串的长度。 分析: 这道题在我半年前开始学算法的时候有写过,不过最后绝对是被虐哭了,主要原因就是无法解决当你向下遍历字符串的时候,遇到隔断后再将其消除不能和上一个连续的有效字串合并。 现在在学了一些算法

  • 3-无重复字符的最长子串2019-03-25 19:50:43

    给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 示例 1: 输入: "abcabcbb"输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。 示例 2: 输入: "bbbbb"输出: 1解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。 示例 3: 输入: "pwwkew"

  • Leetcode 5. 最长回文子串(Longest Palindromic Substring)2019-03-13 21:51:46

    方法一: class Solution { public: string longestPalindrome(string s) { if (s.size() < 2) return s; int n = s.size(), maxLen = 0, start = 0; for (int i = 0; i < n - 1; ++i) { searchPalindrome(s, i, i

  • HIHOcoder 1466 后缀自动机六·重复旋律92019-03-05 12:50:48

    思路 后缀数组+博弈论的好题,首先对两个串都建出SAM,然后题目的要求实际上就是在SAM的trans上转移即可 DAG的博弈是经典问题,然后dfs求出SG函数,两个游戏的组合就是把SG函数异或起来,异或是0就是先手必败,不是0就是先手必胜 然后要求先手必胜,所以就是求异或不为0 接下来递推的求出第k大的

  • 最长上升子序列2019-02-24 17:41:21

    这题就没得暴力前缀和了(老老实实打DP)       输入样例     7     1 7 3 5 9 4 8     输出样例     4     解题思路     1.找子问题     “求序列的前n个元素的最长上升子序列的长度”是个子问题,但这样分解子问题,不具有“无后效性”,因为假设F(n) = x,但可

  • 字符串内无重复字符的最长子串长度2019-02-17 20:39:23

      1 int lengthOfLongestSubstring(char *s) 2 { 3 int size = strlen(s);/*字符串长度*/ 4 int dict[256] = {0}; 5 for(int i=0; i<256; ++i) 6 dict[i] = -1; 7 int maxlen = 0;/*最大无重复字符串长度*/ 8 int start = -1;/*无重复字符

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有