Subarray Product Less Than K - Leetcode 713 - Python

Поделиться
HTML-код
  • Опубликовано: 30 июн 2024
  • 🚀 neetcode.io/ - A better way to prepare for Coding Interviews
    🧑‍💼 LinkedIn: / navdeep-singh-3aaa14161
    🐦 Twitter: / neetcode1
    ⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
    Problem Link: leetcode.com/problems/subarra...
    0:00 - Read the problem
    0:30 - Drawing Explanation
    8:00 - Coding Explanation
    leetcode 713
    #neetcode #leetcode #python

Комментарии • 80

  • @NeetCodeIO
    @NeetCodeIO  3 месяца назад +22

    Yes I use a mouse to draw, in case you still don't believe me. Why? Because with a mouse you can artificially lower the DPI, such that I have to move my hand a few inches to move the mouse cursor by a single inch. This means I can be more precise than if i were using a pen.

    • @spsc07
      @spsc07 3 месяца назад +1

      is your mouse acceleration on?

    • @NeetCodeIO
      @NeetCodeIO  3 месяца назад +3

      I dont think so
      edit: actually yes it is

    • @blakewen4265
      @blakewen4265 3 месяца назад +1

      what software do you use to draw?

    • @varunpenumudi
      @varunpenumudi 3 месяца назад

      What software do you use for drawing?

    • @spsc07
      @spsc07 3 месяца назад

      i guess Windows Whiteboard or something like that@@varunpenumudi

  • @chien-yuyeh9386
    @chien-yuyeh9386 3 месяца назад +17

    Really happy to see you here again!🎉

  • @joelmendez9616
    @joelmendez9616 3 месяца назад +28

    I’d prefer no cam, just to be able to focus better, especially since there is a disparity in light

  • @ragilr1
    @ragilr1 3 месяца назад +19

    Big fan of your work. Would like the earlier format without face. A lot of attention goes to your handsome face than looking at the explanation drawings

    • @kebab4640
      @kebab4640 3 месяца назад +1

      Woah, I said the same thing.

    • @huyennguyenmaingoc468
      @huyennguyenmaingoc468 2 месяца назад +1

      Yes I felt the same thing. Glad you shouted this out XD

  • @user-j5ja95
    @user-j5ja95 3 месяца назад +53

    Hey Neetcode I love your channel and love you and you're super handsome but personally I find having camera on leetcode video to be a bit distracting so I prefer no camera. Nothing personal, I can just focus on content better without camera ❤

    • @dingus2332
      @dingus2332 3 месяца назад +2

      Yeah , agree to that

    • @ashersamuel958
      @ashersamuel958 3 месяца назад +2

      Same here too. Love your content ❤

  • @krishnavamsi9326
    @krishnavamsi9326 3 месяца назад +4

    I prefer videos with face. It's good seeing you explaining . Big fan, been following you since 1 and a half years.

  • @SC2Edu
    @SC2Edu 3 месяца назад +2

    Great as usual.
    I approached it correctly with a sliding window method, but I used slices and I was not using the difference between indices. Great intuition, thanks.

  • @gauravsharma-lu4if
    @gauravsharma-lu4if 3 месяца назад +2

    i have been watching your channel for a while now, you are helped me a lot with learning dsa . keep the camera on . i like it this way

  • @walkastray007
    @walkastray007 3 месяца назад +4

    Hey I really appreciate your consistency on posting videos. Also I like the webcam, now we can see your reaction to the problems as you are explaining them to us. Makes it feel like you're human after all..

  • @MP-ny3ep
    @MP-ny3ep 3 месяца назад +1

    Great explanation as always. Thank you

  • @CS_n00b
    @CS_n00b 3 месяца назад +1

    Here is a better way to understand why getting all subsequences is O(n^2):
    First element needs n operations to get all n subarrays, n-1 for second etc...
    We are summing over numbers from n to 1
    This can be thought of as a discretization of the integral of x from 0 to n
    this is 0.5*n^2 ~ O(n^2)

  • @chisomedoka401
    @chisomedoka401 3 месяца назад

    Bro, your consistency level is off the roof. I’m literally finding it hard to understand why you still leetcoding you already got it all

  • @user-rv1bx8hx4v
    @user-rv1bx8hx4v 3 месяца назад

    Thank you!

  • @KunalSharma-tf3kk
    @KunalSharma-tf3kk 3 месяца назад

    very helpful your videos are...

  • @massimomonticelli6010
    @massimomonticelli6010 3 месяца назад +3

    Hey NeetCode, I like the camera view!

  • @adnanmurtaza6914
    @adnanmurtaza6914 3 месяца назад +7

    The facecam makes the video feel more personable. I can see how it can be distracting, but I think it brings in more value than it takes away.

  • @hristianiliev7979
    @hristianiliev7979 3 месяца назад

    I almost had the solution for this problem and I identified the part where we are missing to count the array [5], but I did not know how to prove how many new subarrays that satisfy the condition we are adding on every correct step. I even went looking for variant formula and combinatorics. Who knew that such a simple observation with the equation is the answer.

  • @yang5843
    @yang5843 3 месяца назад

    Interested in seeing how the feedback for cam-on videos will be!

  • @sri_harsha_dv
    @sri_harsha_dv 3 месяца назад

    I tried to do it with queue instead of sliding window. Despite being O(n) memory solution, the submission passed pretty efficiently. Thanks for O(1) solution. I personally like video with cam included.

  • @rvishwakarma94
    @rvishwakarma94 26 дней назад

    I believe the total number of contiguous subarray is not just n^2. It is n + (n-1)+ (n-2) .....+1 = [n*(n+1)]/2 . So for array of size 4 the total number of contiguous subarrays will be 4+3+2+1 = 10 and not n^2 = 16

  • @romannikiforov5122
    @romannikiforov5122 3 месяца назад

    I was struggling with this problem couple of weeks ago and was upset to know that you didn't have video on it.

  • @viizualares6890
    @viizualares6890 3 месяца назад

    W NeetCode as always. I don't think you have ever missed once.

  • @satyamjha68
    @satyamjha68 3 месяца назад

    Solved it!!

  • @azharuddinkhan1865
    @azharuddinkhan1865 3 месяца назад

    Facecam is great addition. It provides classroom feeling and easy to understand with facial gesture

  • @AdityaBhongade
    @AdityaBhongade 3 месяца назад

    Hey NeetCode, your content is great. It would be better if you increase the audio.

  • @spsc07
    @spsc07 3 месяца назад

    W man, W Webcam I would love to see this I was just doing this question !!

  • @arunmurugan7093
    @arunmurugan7093 3 месяца назад

    I was gonna do the daily today and just saw your upload. I guess ill be back here in 1 hour. 😅

  • @sidhartheleswarapu
    @sidhartheleswarapu 3 месяца назад

    Why l

  • @prashanthkumar0
    @prashanthkumar0 3 месяца назад

    Today's daily problem question ,
    i was searching this with every possible filter to get a solution video from neetcode 😂
    Finally its here...
    I didn't get (r-l+1) logic in other's code ...
    now its clear why
    Thank you

  • @akshaychavan5511
    @akshaychavan5511 3 месяца назад

    NEETly explained! Thank you so much :D
    def numSubarrayProductLessThanK(self, nums: List[int], k: int) -> int:
    res = 0
    p1, p2 = 0, 0
    currentProd = 1
    while p2

    • @Akhillbj
      @Akhillbj 3 месяца назад

      For loop is better, sometimes you still forget to increment p2 , most might not , just in case! You never know

    • @akshaychavan5511
      @akshaychavan5511 3 месяца назад

      @@Akhillbj I agree. Will keep this in mind.

  • @ahmedhamed1154
    @ahmedhamed1154 3 месяца назад

    Another solution
    We can desfine int nxt[N] such that nxt[i] is the next element to the right not equal to 1
    and for each pos i, we can show that the maximum number of jumps is log2(k) which is about 20 jumps
    int mult=1;
    int j=i;
    while(j is not out of the range && mult*a[j]

  • @ankandebnath1056
    @ankandebnath1056 3 месяца назад

    bro keep doing the daily challenges

  • @JSH1994
    @JSH1994 10 дней назад

    cam or no cam it doesn't bother me :) thank you for your work

  • @isseihyodou7111
    @isseihyodou7111 3 месяца назад

    Hey, Neet love your videos man, would love to see the video more focused on the solution, a lot of attention goes on to your handsome face :D

  • @tokkiM3
    @tokkiM3 3 месяца назад

    I like the face cam, keep up the good work.

  • @art4eigen93
    @art4eigen93 3 месяца назад

    will this work for negative values too?

  • @tommyshelby6277
    @tommyshelby6277 3 месяца назад

    with face cam op!

  • @inderlalchandani
    @inderlalchandani 3 месяца назад

    Nice

  • @wcyd69
    @wcyd69 24 дня назад

    there is no way I would think this solution in 1 go, I might know it will be a sliding window problem but the logic behind right - left + 1 would result to counting the subarray? I wont be able to guess or think of it lol.

  • @user-ty7og3rd4z
    @user-ty7og3rd4z 3 месяца назад

    I definetly like the videos with face cam!

  • @ZeckTTV
    @ZeckTTV 3 месяца назад +3

    I like having the camera on, I feel like you do a better job explaining your throught process with it on.

  • @slambam4592
    @slambam4592 3 месяца назад +2

    Without facecam. Feel it can be too distracting

  • @dingus2332
    @dingus2332 3 месяца назад

    I understand the solution , but want to know , why we could not use DP here ? , also like Subarray Sum Equals K , why we were not able to use prefixSumDiff to count map ??

  • @ShashiKanthvarma-lb6xb
    @ShashiKanthvarma-lb6xb 3 месяца назад

    Binary search is very hard to think about

  • @ttowe
    @ttowe 3 месяца назад

    better with camera

  • @chien-yuyeh9386
    @chien-yuyeh9386 3 месяца назад

    🎉🎉🎉🎉🎉

  • @m.kamalali
    @m.kamalali 3 месяца назад

    Hhh , i did the exact same code only difference i used p instead of product

  • @ronbuchanan5432
    @ronbuchanan5432 3 месяца назад

    It's good to see you, don't get me wrong but it also has got me distracted because I want to focus on what you're doing but at the same time you kinda want to glance to the face that talks

  • @pepe-pj9wr
    @pepe-pj9wr 3 месяца назад +3

    WE LOVE THE CAM ON!

  • @kz_cbble9670
    @kz_cbble9670 3 месяца назад

    No camera preffered!
    Keep camera on in story or other videos

  • @alicenNorwood
    @alicenNorwood 2 месяца назад

    I prefer with cam

  • @yang5843
    @yang5843 3 месяца назад

    Java Solution
    class Solution {
    public int numSubarrayProductLessThanK(int[] nums, int k) {
    int prev = 1;
    int rc = 0, i = 0;
    for (int j=0;j

  • @edmonddantes587
    @edmonddantes587 3 месяца назад

    god damnit I was a gnat's c*nt hair away from a working solution. Thanks for the vid, bro

  • @expeditiontoabyss3597
    @expeditiontoabyss3597 3 месяца назад

    i was shocked that I couldn't find a solution this morning in your channel. But now its here, probably some race condition.

  • @ignsock2915
    @ignsock2915 3 месяца назад

    i love you

  • @kahafb
    @kahafb 3 месяца назад

    Like the facecam

  • @nirmalgurjar8181
    @nirmalgurjar8181 3 месяца назад

    I cant see your bag on the floor, so no point in keeping camera :P

  • @krateskim4169
    @krateskim4169 3 месяца назад

    Face cam is good

  • @pastori2672
    @pastori2672 3 месяца назад

    you look so cute bro 🥰

  • @MikeTypes
    @MikeTypes 3 месяца назад +1

    It’s better to have your face on

  • @dipakrajbhar2723
    @dipakrajbhar2723 17 дней назад

    Are you Indian

  • @kebab4640
    @kebab4640 3 месяца назад

    I like it but your jawline makes you look so handsome that you distract me 😍

  • @zweitekonto9654
    @zweitekonto9654 3 месяца назад

    Definitely dont like the face cam. Just because it takes up screen space and serves absolutely no purpose.

  • @shakibrahman
    @shakibrahman 3 месяца назад +2

    sorry you're too handsome it's distracting me

  • @tanishqbhatt9619
    @tanishqbhatt9619 3 месяца назад

    No offense to you, but I'd prefer videos without a face cam

  • @tanish5662
    @tanish5662 3 месяца назад

    no face please

  • @PickNick50
    @PickNick50 3 месяца назад +1

    Please no face cam bro, I come here to study and seeing anyone's face is not gonna help me to learn more. And I low key respect those who maintains anonymity.