leetcode weekly 417.

作者: sixB (6B)   2024-09-29 12:37:23
每次都是contest一結束
放鬆下來之後就想到解法了==
我哭:(
不過幸好有先寫第四題出來 沒有被3卡死
1.2題可以暴力解
不過直接用3.4的解放也完全沒問題
==
3. Count of Substrings Containing Every Vowel and K Consonants II
找出所有substr contain aeiou and just k croissant
原本我是head tail 慢慢推
找到再loop 找tail之後有多少母音( TLE
改成先suffix count 後面連續接幾個母音
找到直接加
醜到不行==等等去看solution
using ll = long long;
class Solution {
public:
//suffix vowel cnt
unordered_map<int , ll> mp;
//<idx, num>
long long countOfSubstrings(string word, int k) {
//slide window
int A = 0, E = 0, I = 0, O = 0, U = 0;
ll cnt = 0;
int head = -1, tail = 0;
int len = word.length();
int cons = 0;
bool mvH = false, mvT = true;
int num = 0;
for(int i = len - 1; i >= 0; i
作者: DJYOSHITAKA (Evans)   2024-09-29 13:03:00
別捲了

Links booklink

Contact Us: admin [ a t ] ucptt.com