Non-Decreasing Array - Leetcode 665 - Python

  Рет қаралды 57,352

NeetCode

NeetCode

Күн бұрын

Пікірлер
@mrditkovich2339
@mrditkovich2339 2 жыл бұрын
Leetcode + Neetcode = Success ! I got selected in Amazon thanks to you 😊
@shashanksingh4510
@shashanksingh4510 2 жыл бұрын
Your channel is the best channel in my subscription list. Usually i get bored listening to the solution videos, but surprisingly that doesn't happen during your videos. Keep posting videos for the people like me so that i can also end up in the place you are currently in🙌🙌
@NeetCode
@NeetCode 2 жыл бұрын
Glad they're helpful!
@john_paul
@john_paul 2 жыл бұрын
Thanks for this! Really like the brevity of your walk-throughs on these questions, and it helps me a lot to try and translate them to different languages like C or C++ to better understand your explanations. Keep it up! :D
@fazilkagdi3290
@fazilkagdi3290 2 жыл бұрын
Please never stop making these. I really like them.
@xueweijiang746
@xueweijiang746 Жыл бұрын
I'm glad that I solved this question on my own which I think is a result of following your channel. Even though the code that I wrote is a lot less elegant than yours but I'm glad that my thought is pretty much the same as yours and the time complexity is the same. Thank you for doing these videos!
@nischayagrawalVlogs
@nischayagrawalVlogs Жыл бұрын
Bro I just love the way u explain things by considering various types of test cases. Mad Respect for your efforts. Seriously !
@johnvanschultz2297
@johnvanschultz2297 2 жыл бұрын
Never thought of using index - 2. I feel like I would never come up with that in an interview
@ChiragVithlani
@ChiragVithlani 2 жыл бұрын
You have superpower of explaining difficult things in easy words. The best part is you are teaching "how to think". BTW, what tool you use for drawing ?
@bill312r
@bill312r 2 жыл бұрын
i'm curious about that too does anyone know the name of the tool?
@chesslectures9081
@chesslectures9081 2 жыл бұрын
watched it 3 times , neat and clean explanation
@Josh-tu9ji
@Josh-tu9ji 2 жыл бұрын
Thanks for going over the daily leetcode challenge
@tylerrussell7560
@tylerrussell7560 2 жыл бұрын
Can a stack be used to eliminate the edge cases?
@volodymyr.kushnir
@volodymyr.kushnir 2 жыл бұрын
Assuming you are writing code which potentially should be possible to handle same task with 2+ substitutions. In such case you rather should go for increasing right number. This way you don't need to re-check numbers on left side again and can proceed validating numbers on the right which are still not verified. So your alg will be smth like O(n) with modifying right number and O(n)*log with modifying left.
@vasujain1970
@vasujain1970 2 жыл бұрын
Ah leetcode daily challenge questions are the best soln to provide. Love your content. Had a question regarding your Google interview, what if one cannot come up wid something better than sub optimal soln in limited time. What's the best way to optimise for time? Thanks!
@NeetCode
@NeetCode 2 жыл бұрын
Best suggestion I have is to talk about possible ways to improve it with the interviewer and they might point you in the right direction.
@varunshrivastava2706
@varunshrivastava2706 2 жыл бұрын
My solution cleared 320 test cases out of 335. And I wasn't able to come up with a way to handle edge cases like [3,4,2,3]. It feels bad when you are this close!! Although good explanation!!!!!
@yashvirani8299
@yashvirani8299 2 жыл бұрын
Same buddy 😂
@NOOBGamer-zt6jh
@NOOBGamer-zt6jh 2 жыл бұрын
same dude and then I started thinking about 3 pointer and O(n^2) solution's xd
@rahatsshowcase8614
@rahatsshowcase8614 2 жыл бұрын
4 Lines JS code! After watching this video I discovered something deadlock 4 pattern! : var checkPossibility = function(nums) { let breakage = 0; for (let i = 0; i < nums.length; i++) { const num = nums[i] if (num < nums[i - 1]) breakage++ if (breakage > 1) return false if (nums[i - 1] > nums[i + 1] && num > nums[i + 2]) //[4,9,2,5] //deadlock 4 pattern return false } return true };
@ethanwong2272
@ethanwong2272 2 жыл бұрын
We sent the left pointer to go up and the right pointer to go down. Case 1: left == right -> true Case 2: right-left > 1 -> false Case 3: left + 1 == right if left == start point -> true if right == end point -> true if nums[left - 1]
@krzysztofsobocinski2207
@krzysztofsobocinski2207 2 жыл бұрын
You can do only the else part because all this function has to do is to check the possibility. It is not necessary to make array non-decreasing.
@anthonyuccello1458
@anthonyuccello1458 2 жыл бұрын
Shoutout to NeetCode for helping me get a much better job!
@NeetCode
@NeetCode 2 жыл бұрын
Congratulations 🎉
@AvaSession7
@AvaSession7 2 жыл бұрын
i love your channel neetcode. it’s been super helpful and i’ve made it to the final round at google in large part due to your help. thank you. do you think you’ll ever cover System Design questions?
@NeetCode
@NeetCode 2 жыл бұрын
Yeah I've been wanting to do it for a while but been busy. I will definitely start by August tho!
@AvaSession7
@AvaSession7 2 жыл бұрын
@@NeetCode Awesome! Looking forward to it. Thank you = )
@bitlandsaga
@bitlandsaga 7 ай бұрын
Thanks for such an easy explanation 🙌
@theodoregolob4191
@theodoregolob4191 2 жыл бұрын
Thanks for the video and for sharing your solution! Question: Isn’t changing the state of an input for a method that is supposed to check its state bad practice?
@sharathkumar8338
@sharathkumar8338 2 жыл бұрын
Love you man thanks a lot for these videos. Even my friend didn't help me but you are doing it.
@shibosheng4205
@shibosheng4205 2 жыл бұрын
Hey man you are so cool and the best coding teacher of all time. Could you also solve 797. All Paths From Source to Target some day. Thx
@reflectedillumination2610
@reflectedillumination2610 2 жыл бұрын
Neighbour's lawn mower is becoming a frequent guest 😂 BTW great explanation as always 🙌
@NeetCode
@NeetCode 2 жыл бұрын
I know, I was almost finished too 😭
@sw6273
@sw6273 2 жыл бұрын
Thank you so much for your videos! I'm an incoming cs major at Georgia Tech. I want an internship with a FAANG or hot startup company for summer 2023. I currently don't have any knowledge of data structures and algorithms. How long do you think it would take to be confident for interviews at such companies if I spent 10 hours every week learning and leet coding? If it helps to know, I'm doing The Odin Project, which I hope to finish before school starts in late August, and I also need to build 3~4 personal projects before I start preparing for these interviews.
@sushantjha1033
@sushantjha1033 2 жыл бұрын
wht you are doing is amazing man! keep it up
@sajalhsn13
@sajalhsn13 2 жыл бұрын
How about this solution? find the length of non-decreasing subsequence in the array. if it is + 1 >= length of original array (which means we need to change atmost one element) then return true or false. complexity is (nlogn)
@fa11en1ce
@fa11en1ce 2 жыл бұрын
Why pick a more inefficient solution?
@sajalhsn13
@sajalhsn13 2 жыл бұрын
@@fa11en1ce nlogn is very close to n. also it is easy to think when you know the classical solution.
@patrickkurth697
@patrickkurth697 2 жыл бұрын
Thanks for the videos. I have a much better understanding of programming because of videos like this. Could you explain why at 8:15 you need to do the for loop with the - 1? Is it because if we didn't we would have an extra for loop we would go through?
@alliswellbrochill9937
@alliswellbrochill9937 2 жыл бұрын
Basically to avoid array index out of bound since we are using comparing the current element with next element
@mastermindful1051
@mastermindful1051 2 жыл бұрын
thanks for the efforts. i'm curious, what tools are you using to make the videos? i love the online whiteboard/blackboard i think it might be pretty good to practice with one self
@RN-jo8zt
@RN-jo8zt 11 ай бұрын
why it's not working if i just flip the if cond i==0 || nums[i-1]
@nickheyer
@nickheyer 2 жыл бұрын
So well explained! I'm going to crush my Amazon interview because of you! I'll send you a postcard if it happens :D
@amosluesun585
@amosluesun585 2 жыл бұрын
your videos are extremely helpful to me!! thank you
@resetengineering
@resetengineering 2 жыл бұрын
when we realise nums[i+1] >= nums[i] and nums [i-1] then why are we doing nums[i] = nums[i+1] Isn't this already non-decreasing in nature?
@Username-gu3un
@Username-gu3un 2 жыл бұрын
Could this be optimized with binary search?
@adityavikramsingh4105
@adityavikramsingh4105 2 жыл бұрын
Hey can you please do a video on leetcode problem: 968 (Binary Tree Cameras). It would be very helpful
@AdilKelawala
@AdilKelawala Жыл бұрын
Why are we adding 3 in the begining of the array? Please, anyone can explain it to me.
@dixztube
@dixztube 2 жыл бұрын
My goodness this was very wel explained
@godza4735
@godza4735 2 жыл бұрын
Can you solve some question about binary search trees?
@dhrumilparekh8554
@dhrumilparekh8554 Жыл бұрын
try testing [4,2,1] with your code
@fatihorhan9355
@fatihorhan9355 2 жыл бұрын
Shouldn't this be an easy question?
@hantinglu8050
@hantinglu8050 2 жыл бұрын
Thanks, nice explanations as usual!
@elvisgarcia1822
@elvisgarcia1822 2 жыл бұрын
What is the program name that you use to draw ?
@indianajones330
@indianajones330 Жыл бұрын
please solve this problem 🙏 44. Wildcard Matching
@tt095
@tt095 Жыл бұрын
I kind of get it. But can't see it clearly in my head
@piyushupadhyay8361
@piyushupadhyay8361 2 жыл бұрын
hey bro please make a solution of problem leetcode 686 (repeated string match)
@zaqxswcdevfr40
@zaqxswcdevfr40 2 жыл бұрын
Thanks!
@VijayPatel-ez4lp
@VijayPatel-ez4lp Жыл бұрын
thanku so much
@TechOnScreen
@TechOnScreen 2 жыл бұрын
Java solution, much easier approach without even changing the input array. class Solution { public boolean checkPossibility(int[] nums) { boolean status=true; for(int i=1;i
@datascience3008
@datascience3008 Жыл бұрын
understood
@rajatarora8105
@rajatarora8105 2 жыл бұрын
Can you solve leetcode 328.
@aditijain2448
@aditijain2448 2 жыл бұрын
amazing!!!
@jaybijwe9371
@jaybijwe9371 2 жыл бұрын
AWESOME 🍎
@kitgary
@kitgary 2 жыл бұрын
好像很難, 不是很明白!
@hAmIdUlHoQuE821
@hAmIdUlHoQuE821 2 жыл бұрын
Will I get offer from google or any faang company? Pls, pls, pls say. My Career: Education : CSE 2nd Year (2022) Codejam rank: 523. (2021) 2 yrs+ experience in data science, web development with django, software development using c#. Langs: c,c++,python,java,c#
@電腦騙徒剋星
@電腦騙徒剋星 2 жыл бұрын
if you really rank top 500 in Google code jam you probably won't be so dumb to ask thos question
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 148 М.
Python for Coding Interviews - Everything you need to Know
26:18
小路飞还不知道他把路飞给擦没有了 #路飞#海贼王
00:32
路飞与唐舞桐
Рет қаралды 87 МЛН
Why no RONALDO?! 🤔⚽️
00:28
Celine Dept
Рет қаралды 54 МЛН
The Singing Challenge #joker #Harriet Quinn
00:35
佐助与鸣人
Рет қаралды 44 МЛН
Maximum Performance of a Team - Leetcode 1383 - Python
14:53
NeetCode
Рет қаралды 31 М.
10 Crazy Python Operators That I Rarely Use
11:37
Indently
Рет қаралды 43 М.
Number of Zero-Filled Subarrays - Leetcode 2348 - Python
10:55
NeetCodeIO
Рет қаралды 10 М.
How to: Work at Google - Example Coding/Engineering Interview
24:02
Life at Google
Рет қаралды 7 МЛН
Non-decreasing Array | Live Coding with Explanation | Leetcode - 665
7:43
Algorithms Made Easy
Рет қаралды 13 М.
4Sum - Leetcode 18 - Python
15:28
NeetCode
Рет қаралды 82 М.
Contiguous Array - Leetcode 525 - Python
15:41
NeetCodeIO
Рет қаралды 28 М.
This Algorithm is 1,606,240% FASTER
13:31
ThePrimeagen
Рет қаралды 852 М.
Search Suggestions System - Leetcode 1268 - Python
13:16
NeetCode
Рет қаралды 45 М.
小路飞还不知道他把路飞给擦没有了 #路飞#海贼王
00:32
路飞与唐舞桐
Рет қаралды 87 МЛН