Тёмный

55. Jump Game || 4 examples to build logic + code 

Code with Alisha
Подписаться 29 тыс.
Просмотров 14 тыс.
50% 1

Given an array of non-negative integers nums, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that position.
Determine if you are able to reach the last index.
Example 1:
Input: nums = [2,3,1,1,4]
Output: true
Explanation: Jump 1 step from index 0 to 1, then 3 steps to the last index.
Example 2:
Input: nums = [3,2,1,0,4]
Output: false
Explanation: You will always arrive at index 3 no matter what. Its maximum jump length is 0, which makes it impossible to reach the last index.
Link to challenge: leetcode.com/p...

Опубликовано:

 

12 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 32   
@thegreekgoat98
@thegreekgoat98 Год назад
Your explanation was so good that, 8:30 into the video and I coded my solution and got an AC. Simple and Brilliant stuff.
@girirajchandak4519
@girirajchandak4519 Год назад
watched just for 3minutes and was able to code the solution.. Best one..
@gurmehakkaur7339
@gurmehakkaur7339 Год назад
Impressive explanation! I solved it correctly on my own without checking your code.
@ssh245724
@ssh245724 6 месяцев назад
This is an amazing inductive prove!
@pain9569
@pain9569 11 месяцев назад
Your explaination is amazing mam, coded it on own 😁
@saitejaswikallepalli170
@saitejaswikallepalli170 Год назад
Mam your approach and explanation are too good mam
@wizardfire2270
@wizardfire2270 Год назад
yrr.. your explanations are best really!!
@Pratham__Sharma
@Pratham__Sharma Год назад
Great Explanation 😊
@Shubham-zu1zh
@Shubham-zu1zh Год назад
good explanation
@noone1000_xyz
@noone1000_xyz 9 месяцев назад
too good
@avikmullick75
@avikmullick75 Год назад
Thank you for the intuition and explanation
@abudanish196
@abudanish196 7 месяцев назад
Nice!
@aamirhussainwani6613
@aamirhussainwani6613 Год назад
Ma'am can you tell me what is the intuition behind adding "i" in the condinition loop if( nums[i]+i>=index) What is the intuition of adding i here?
@shahilpatel6626
@shahilpatel6626 Год назад
nums[i] is the maximum number of jumps that you can make to the right, and i is the distance from the left, also your index is calculated from left end. So, your i (distance of nums[i[ from 0) + nums[i] (max. no. of jumps you can make to right) >= index (position you want to reach)
@harmangrewal3664
@harmangrewal3664 Год назад
brilliant explanation😀
@abhishekverma7604
@abhishekverma7604 Год назад
got the base logic,thanks a lot
@abhinavraj4820
@abhinavraj4820 Год назад
Well explained....
@ShwetaSingh-qi5sz
@ShwetaSingh-qi5sz Год назад
Just wow😮 thanks yr
@jagratgupta8392
@jagratgupta8392 Год назад
nice explaination didi
@rajeevcbhatia
@rajeevcbhatia Год назад
great explanation!
@piyush2750
@piyush2750 2 года назад
We can check if first element is 0 then directly return false . No need to loop whole array
@visase2036
@visase2036 2 года назад
1,0,0,0,1 ---> it fails! if you think checking 0 can be done on every index then how about 1,2,0,1,1 From 2nd position(1 based index) you can either need to jump 1 step or 2 steps , since 1 step is giving you 0 , you have to backTrack and jump 2 steps to reach the destination. So looping is mandatory !
@anuragdeol9474
@anuragdeol9474 Год назад
@@visase2036I think he meant if the element at 0th index is 0, then we can return false without checking further, just a small optimization.
@reshmaparveen6679
@reshmaparveen6679 3 года назад
Too good.and v useful
@shubhanshukakkar973
@shubhanshukakkar973 Год назад
wow thanks easy solution
@ACUCSPRADEEPB-up9ne
@ACUCSPRADEEPB-up9ne Год назад
Great 👍
@raj_kundalia
@raj_kundalia Год назад
thank you!
@princepriyo3643
@princepriyo3643 Год назад
Great explaination 🔥🔥
@vedantsingh1801
@vedantsingh1801 Год назад
wrong code please check the logic mam nit running all the cases bool canJump(vector& nums) { int index = nums.size() -1 ; for(int i = nums.size() -1 ; i>=0 ;i--) { if(nums[i] + i >=index) { index = i; } } if(index = 0) { return true; } else { return false; } }
@vinaykenguva362
@vinaykenguva362 3 года назад
nice
@himanshugupta8430
@himanshugupta8430 Год назад
💋💋💋💋💋💋💋💋💋
Далее
Leetcode 62. Unique Paths || Code + Explanation
12:06
Эконом такси в твоем городе 😂
00:59
Standoff 2 is a true horror! #standoff #horror #meme
00:13
Google Coding Interview With A Competitive Programmer
54:17
why are switch statements so HECKIN fast?
11:03
Просмотров 408 тыс.
LeetCode 55. Jump Game (Algorithm Explained)
10:06
Просмотров 77 тыс.
Эконом такси в твоем городе 😂
00:59