Back to back WINS! Leetcode Weekly Contest 375

Ғылым және технология

:)
#leetcode #python #coding

Пікірлер: 17

  • @prchaser2081
    @prchaser20817 ай бұрын

    You're the GOAT!!! Any tips on learning coding and getting better at LeetCode or CP?

  • @Ani_86_
    @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

    @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

  • @renzheng7845
    @renzheng78457 ай бұрын

    Welcome back. I look forward to you taking #1.

  • @numb3r5

    @numb3r5

    7 ай бұрын

    If I can win the next contest then I'll be back to #1 :)

  • @numb3r5
    @numb3r57 ай бұрын

    Looks like I'm back to #2 rating in the world!

  • @Ani_86_

    @Ani_86_

    7 ай бұрын

    that's great, congrats

  • @Profnegi
    @Profnegi7 ай бұрын

    no.1 amazing...bro

  • @gradientO
    @gradientO7 ай бұрын

    Woah

  • @johnapple3471
    @johnapple34717 ай бұрын

    brio this guy sits next to my class

  • @kaushalshinde3920
    @kaushalshinde39207 ай бұрын

    genius

  • @uraharakisuke5305
    @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)

  • @dipankaryadav5598
    @dipankaryadav55987 ай бұрын

    Can you share your leetcode templates ?

  • @numb3r5

    @numb3r5

    7 ай бұрын

    Most of my templates are at github.com/Joshc88/CPTemplates

  • @Demodulator7
    @Demodulator77 ай бұрын

    Orz

  • @matthewlim-dot-ml
    @matthewlim-dot-ml7 ай бұрын

    what is your occupation? are you still studying or do you currently work? well done

  • @numb3r5

    @numb3r5

    7 ай бұрын

    I'm a 1st year university student at the University of Cambridge.

Келесі