You're the GOAT!!! Any tips on learning coding and getting better at LeetCode or CP?
@Ani_86_7 ай бұрын
3rd task can be easily done via sliding window, wherein I calculate the total number of subarrays of the given array and then subtract the subarrays which are not valid, here's take a quick look at this code: #define ll long long class Solution { public: long long countSubarrays(vector& nums, int k) { int n = nums.size(); ll count = n*1LL*(n+1)/2; ll i = 0, j = 0; int maxu = 0; for(auto x : nums)maxu = max(maxu, x); int u = 0; while(j if(nums[j] == maxu){ u++; } while(u >= k){ if(nums[i] == maxu){ u-=1; } i++; } count -= j-i+1; j++; } return count; } };
@numb3r5
7 ай бұрын
Yeah I realised after the contest, but it wasn't my first thought... so I didn't want to waste time in contest thinking more
@renzheng78457 ай бұрын
Welcome back. I look forward to you taking #1.
@numb3r5
7 ай бұрын
If I can win the next contest then I'll be back to #1 :)
@numb3r57 ай бұрын
Looks like I'm back to #2 rating in the world!
@Ani_86_
7 ай бұрын
that's great, congrats
@Profnegi7 ай бұрын
no.1 amazing...bro
@gradientO7 ай бұрын
Woah
@johnapple34717 ай бұрын
brio this guy sits next to my class
@kaushalshinde39207 ай бұрын
genius
@uraharakisuke53057 ай бұрын
I'm fucking dumb i did all the interval merging etc in the 4th one, but couldn't realise the answer would be 2^(x-1)
@dipankaryadav55987 ай бұрын
Can you share your leetcode templates ?
@numb3r5
7 ай бұрын
Most of my templates are at github.com/Joshc88/CPTemplates
@Demodulator77 ай бұрын
Orz
@matthewlim-dot-ml7 ай бұрын
what is your occupation? are you still studying or do you currently work? well done
@numb3r5
7 ай бұрын
I'm a 1st year university student at the University of Cambridge.
Пікірлер: 17
You're the GOAT!!! Any tips on learning coding and getting better at LeetCode or CP?
3rd task can be easily done via sliding window, wherein I calculate the total number of subarrays of the given array and then subtract the subarrays which are not valid, here's take a quick look at this code: #define ll long long class Solution { public: long long countSubarrays(vector& nums, int k) { int n = nums.size(); ll count = n*1LL*(n+1)/2; ll i = 0, j = 0; int maxu = 0; for(auto x : nums)maxu = max(maxu, x); int u = 0; while(j if(nums[j] == maxu){ u++; } while(u >= k){ if(nums[i] == maxu){ u-=1; } i++; } count -= j-i+1; j++; } return count; } };
@numb3r5
7 ай бұрын
Yeah I realised after the contest, but it wasn't my first thought... so I didn't want to waste time in contest thinking more
Welcome back. I look forward to you taking #1.
@numb3r5
7 ай бұрын
If I can win the next contest then I'll be back to #1 :)
Looks like I'm back to #2 rating in the world!
@Ani_86_
7 ай бұрын
that's great, congrats
no.1 amazing...bro
Woah
brio this guy sits next to my class
genius
I'm fucking dumb i did all the interval merging etc in the 4th one, but couldn't realise the answer would be 2^(x-1)
Can you share your leetcode templates ?
@numb3r5
7 ай бұрын
Most of my templates are at github.com/Joshc88/CPTemplates
Orz
what is your occupation? are you still studying or do you currently work? well done
@numb3r5
7 ай бұрын
I'm a 1st year university student at the University of Cambridge.