Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note:You may assume the string contain only lowercase letters. 这道题确实没有什么难度,我们只要用...
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note: You may assume the string contain only lowercase letters. 思路 1. use int array to simpli...
LeetCode 387: 字符串中的第一个唯一字符 First Unique Character in a String 题目: 给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。 Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1. ...
1、题目 Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. 1. 2. 3. 4. 5. 2、代码实现 public class Solution { public int firstUniqCha...
387 First Unique Character in a String 字符串中的第一个唯一字符 TODO Easy 392 Is Subsequence 判断子序列 TODO Easy 395 Longest Substring with At Least K Repeating Characters 至少有 K 个重复字符的最长子串 TODO Medium 409 Longest Palindrome 最长回文串 Java Easy 415 Add Strings 字符串相加 Java Ea...
Longest Repeating Character Replacement - https://leetcode.com/problems/longest-repeating-character-replacement/ Minimum Window Substring - https://leetcode.com/problems/minimum-window-substring/ Valid Anagram - https://leetcode.com/problems/valid-anagram/ Group Anagrams - https://leetcode.com/problem...
int characterReplacement(string s, int k) { int len = s.size(); int l = 0, r = 0; int res = 0, count = 0, kk = 0; //kk代表当前滑窗中被替换的字符数量; if (len == 0) return 0; char pre = s[0]; int next_l = 0; //遇到第一个不同的字符时,把它预先设置为下一个...
Explanation: Replace the two 'A's with two 'B's or vice versa. Example 2: Input: s = "AABABBA", k = 1 Output: 4 Explanation: Replace the one 'A' in the middle with 'B' and form "AABBBBA". The substring "BBBB" has the longest repeating letters, which is 4. ...
描述:有一个手表,假设小时范围是0~11,分钟范围是0~59。如果时和分的二级制表示总共有N个1,求所有可能的时间。 //#401Description: Binary Watch | LeetCode OJ 解法1:水题。 // Solution 1: Easy. 代码1 //Code 1 402 Remove K Digits // #402 移除K个数字 ...
Longest Repeating Character Replacement Leetcode 76. Minimum Window Substring Leetcode 3. Longest Substring Without Repeating Characters Leetcode 1004 Max Consecutive Ones III Leetcode 1658 Minimum Operations to Reduce X to Zero 宽度优先搜索(BFS):面试中最常考的 基础知识: 常见的BFS用来解决什么问题?