描述 给定一个字符串 s 和一些长度相同的单词 words。找出 s 中恰好可以由 words 中所有单词串联形成的子串的起始位置。 注意子串要与 words 中的单词完全匹配,中间不能有其他字符,但不需要考虑 words 中单词串联的顺序。 示例 1: 输入: s = "barfoothefoob ...
分类:
编程语言 时间:
2021-02-24 13:19:03
阅读次数:
0
404 按理说也可以递归做。 public static int sumOfLeftLeaves(TreeNode root) { int total = 0; LinkedList<TreeNode> stack = new LinkedList<>(); stack.push(root); wh ...
分类:
其他好文 时间:
2021-02-23 14:11:21
阅读次数:
0
托普利茨矩阵 给你一个 m x n 的矩阵 matrix 。如果这个矩阵是托普利茨矩阵,返回 true ;否则,返回 false 。 如果矩阵上每一条由左上到右下的对角线上的元素都相同,那么这个矩阵是托普利茨矩阵 。 示例1 输入:matrix = [[1,2,3,4],[5,1,2,3],[9,5 ...
分类:
其他好文 时间:
2021-02-23 14:07:50
阅读次数:
0
题目描述 题目链接 思路1 Hash表 很直接,代码略 由于题目的follow-up要求空间复杂度O(1),所以,这个方法其实并不是最优解。 思路2 一次删除两个不同的数 一次删除两个不同的数,如果存在majority element,那么这个majority element一定会最后剩下来, 但是 ...
分类:
其他好文 时间:
2021-02-23 14:06:57
阅读次数:
0
Given a string s of lower and upper case English letters. A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where ...
分类:
其他好文 时间:
2021-02-22 12:38:24
阅读次数:
0
题目描述 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的字母异位词。 说明: 你可以假设字符串只包含小写字母。 原题请参考链接https://leetcode-cn.com/problems/valid-anagram/ 题解 方法一?【排序】 class Solution: ...
分类:
其他好文 时间:
2021-02-22 12:20:42
阅读次数:
0
JAVA 暴力解法: public final int networkDelayTime(int[][] times, int n, int k) { Map<Integer, List<Integer[]>> map = new HashMap<Integer, List<Integer[]>>( ...
分类:
编程语言 时间:
2021-02-22 12:12:04
阅读次数:
0
1.第一题就给我整蒙了 1.1我的思路,看能不能获取到一个列表的(里面全是0,1)的最大连续长度 def get_max_one(A): A = [str(i) for i in A] s1 = ''.join(A) #我想把列表变成字符串,然后按0 split ,列表里必须都是字符串 A = s1 ...
分类:
其他好文 时间:
2021-02-20 12:40:12
阅读次数:
0
Given an integer n, return the number of structurally unique BST's (binary search trees) which has exactly n nodes of unique values from 1 to n. Examp ...
分类:
其他好文 时间:
2021-02-20 12:13:36
阅读次数:
0
题目描述: 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素不能使用两遍。 示例: 给定 nums = [2, 7, 11, 15], target = 9 因为 ...
分类:
其他好文 时间:
2021-02-19 13:36:23
阅读次数:
0