原题链接在这里:https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters/ 题目: Given a string S, return the number of substrings of length K with no repeated characters. Example 1: Input: S = "havefunonleetcode", K = 5 Output: 6…
Given a non-empty array of integers, return the k most frequent elements. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input: nums = [1], k = 1 Output: [1] Note: You may assume k is always valid, 1 ≤ k ≤ number of unique ele…
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C#版 - Leetcode 347. Top K Frequent Elements - 题解 在线提交: https://leetcode.com/problems/top-k-frequent-elements/ Description Given a non-empty array of integers…
Given a non-empty list of words, return the k most frequent elements. Your answer should be sorted by frequency from highest to lowest. If two words have the same frequency, then the word with the lower alphabetical order comes first. Example 1: Inpu…
LeetCode:前K个高频单词[692] 题目描述 给一非空的单词列表,返回前 k 个出现次数最多的单词. 返回的答案应该按单词出现频率由高到低排序.如果不同的单词有相同出现频率,按字母顺序排序. 示例 1: 输入: ["i", "love", "leetcode", "i", "love", "coding"], k = 2 输出: ["i", "lov…
LeetCode:前K个高频元素[347] 题目描述 给定一个非空的整数数组,返回其中出现频率前 k 高的元素. 示例 1: 输入: nums = [1,1,1,2,2,3], k = 2 输出: [1,2] 示例 2: 输入: nums = [1], k = 1 输出: [1] 说明: 你可以假设给定的 k 总是合理的,且 1 ≤ k ≤ 数组中不相同的元素的个数. 你的算法的时间复杂度必须优于 O(n log n) , n 是数组的大小. 题目分析 我们还是基于优先队列或者说是小顶堆来AC这…
LeetCode:第K个排列[60] 题目描述 给出集合 [1,2,3,…,n],其所有元素共有 n! 种排列. 按大小顺序列出所有排列情况,并一一标记,当 n = 3 时, 所有排列如下: "123""132""213""231""312""321" 给定 n 和 k,返回第 k 个排列. 说明: 给定 n 的范围是 [1, 9].给定 k 的范围是[1,  n!]. 示例 1: 输入…
[LeetCode]718. Maximum Length of Repeated Subarray 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/maximum-length-of-repeated-subarray/description/ 题目描述: Given two integer arr…
LeetCode(2) || Add Two Numbers && Longest Substring Without Repeating Characters 题记 刷LeetCode第二天,今天做了两道题,速度比我想的要慢,看样子两个月的目标有点难,尽力吧.今天主要做了Add Two Numbers和Longest Substring Without Repeating Characters 两道题,下面就来看下这两道题吧. 题一:Add Two Numbers 题目内容 You ar…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:暴力解法(TLE) 方法二:连续子串计算 日期 题目地址:https://leetcode.com/problems/baseball-game/description/ 题目描述 Give a string s, count the number of non-empty (contiguous) substrings that have…