leetcode-cn链接 https://leetcode-cn.com/problems/substring-with-concatenation-of-all-words/ 一、题目 给定一个字符串 s 和一些长度相同的单词 words。找出 s 中恰好可以由 words 中所有单词串联形成的 ...
分类:
其他好文 时间:
2020-03-14 01:16:37
阅读次数:
55
一、题目说明 题目128. Longest Consecutive Sequence,给定一列无序的整数,计算最大连续的整数的个数。复杂度要求是O(n),难度是Hard! 二、我的解答 这个题目解答方法包括,brute force、sort、hash。但brute force和sort的复杂度不符合 ...
分类:
其他好文 时间:
2020-03-12 18:50:11
阅读次数:
47
class Solution { public int lengthOfLongestSubstring(String s) { int[] dict = new int[256]; Arrays.fill(dict, -1); int maxLen = 0, start = -1; for (in ...
分类:
编程语言 时间:
2020-03-12 14:37:50
阅读次数:
71
最近经常用到这个函数,但是总是用了忘,忘了查,干脆写一篇整理一下。 Substring 是用来截取字符串的函数。 当只传入一个整形参数a的时候,(a>=0)代表从该位置起(有包括该位置),截取字符串剩下的所有字符串。 当传入两个整形参数a,b的时候,(a>=0,a+b<=字符串的总长度),代表从a开 ...
class Solution { public String longestPalindrome(String s) { if (s == null || s.length() < 1) return ""; int start = 0; int end = 0; for (int i = 0; i ...
分类:
编程语言 时间:
2020-03-12 14:14:41
阅读次数:
65
Given a binary tree root, a ZigZag path for a binary tree is defined as follow: Choose any node in the binary tree and a direction (right or left). If ...
分类:
其他好文 时间:
2020-03-12 09:26:04
阅读次数:
76
首先声明的是这种解法非常非常的原始和不优雅,甚至比暴力递推还要臭长。 对于最长回文子串这种经典的老题目,有很多亮眼的解法,比如与逆序串取交集。 但我们解决问题不能总是依靠这种眼前一亮(虽然很少亮那么一下),我们应该有一些通用的思考方法,可以用来解决绝大部分问题。 问题的解决都有递归和递推的两种描述, ...
分类:
其他好文 时间:
2020-03-11 01:28:31
阅读次数:
68
LeetCode 1372. Longest ZigZag Path in a Binary Tree二叉树中的最长交错路径【Medium】【Python】【DFS】 Problem "LeetCode" Given a binary tree , a ZigZag path for a binar ...
分类:
编程语言 时间:
2020-03-08 15:55:09
阅读次数:
79
Given the string s, return the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must ...
分类:
其他好文 时间:
2020-03-08 09:32:42
阅读次数:
81
一、Scanner的概述和方法介绍 * A:Scanner的概述 * B:Scanner的构造方法原理 * Scanner(InputStream source) * System类下有一个静态的字段: * public static final InputStream in; 标准的输入流,对应着 ...
分类:
其他好文 时间:
2020-03-07 10:04:23
阅读次数:
65