题目描述 题目链接 思路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
给定一个长度为 n 的整数数组 A 。 假设 Bk 是数组 A 顺时针旋转 k 个位置后的数组,我们定义 A 的“旋转函数” F 为: F(k) = 0 * Bk[0] + 1 * Bk[1] + ... + (n-1) * Bk[n-1]。 计算F(0), F(1), ..., F(n-1)中的最 ...
分类:
其他好文 时间:
2021-02-19 13:03:58
阅读次数:
0
链接:https://leetcode-cn.com/problems/minimum-number-of-arrows-to-burst-balloons discription: 在二维空间中有许多球形的气球。对于每个气球,提供的输入是水平方向上,气球直径的开始和结束坐标。由于它是水平的,所以纵 ...
分类:
其他好文 时间:
2021-02-18 13:34:55
阅读次数:
0
Given an array of non negative integers, return the maximum sum of elements in two non overlapping (contiguous) subarrays, which have lengths and . (F ...
分类:
移动开发 时间:
2021-02-18 12:53:23
阅读次数:
0