![Programmers Zone](/img/default-banner.jpg)
- 141
- 307 613
Programmers Zone
India
Registrace 8. 05. 2020
The Programmers Zone
It's your one stop destination where you can learn from zero to advanced.
Learn various languages from scratch till advanced.
Remember journey of miles begins with a single step.
Love the concepts ❤️
Comment your needs
Geeks for Geeks, hacker rank , hacker earth, SPOJ
Videos every day
It's your one stop destination where you can learn from zero to advanced.
Learn various languages from scratch till advanced.
Remember journey of miles begins with a single step.
Love the concepts ❤️
Comment your needs
Geeks for Geeks, hacker rank , hacker earth, SPOJ
Videos every day
2400 Number of Ways to Reach a Position After Exactly k Steps | Zero to FAANG Kunal | Assignment
2400 Number of Ways to Reach a Position After Exactly k Steps | Zero to FAANG Kunal | Assignment | Leetcode | Shapnesh Tiwari
Problem link :
leetcode.com/problems/number-of-ways-to-reach-a-position-after-exactly-k-steps/
Complete Java + DSA + Interview Preparation + CP Course
czcams.com/play/PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ.html
Hi, thanks for watching our video about Arrays in Java
In this video we’ll walk you through:
- Brute Force
- Efficient approach
- Solution Code
TIMESTAMPS
Intro
Explanation begins
IDE solution
ABOUT OUR CHANNEL
Our channel is all about Programming. We cover lots of cool stuff such as solution to problems, concept explanation and tricks to master CP
Check out our channel here:
czcams.com/channels/qtYay7YwH8JdZxDqpVEPvg.html
Don’t forget to subscribe!
CHECK OUT OUR OTHER Playlists
GeeksforGeeks playlist:
czcams.com/play/PLDaU_TBYXoirv-848r81oHLSArcBrjIe7.html
Complete C++ Course playlist:
czcams.com/play/PLDaU_TBYXoio9L1qRpTrtzK9JJAwFLMSj.html
CodeChef Playlist:
czcams.com/play/PLDaU_TBYXoip_JFIo0U-Nl2dNA_ZMsd2z.html
HackerRank playlist:
czcams.com/play/PLDaU_TBYXoirMjgzW59T_XMyT5yRZ7ht_.html
LeetCode problems
czcams.com/play/PLDaU_TBYXoirsirbg6feNCKk3oPRn6M7w.html
FIND US AT
www.waadanibhao.wordpress.com
GET IN TOUCH
Contact us on hopesalivenow@gmail.com
2400. Number of Ways to Reach a Position After Exactly k Steps
Medium
86
35
Add to List
Share
You are given two positive integers startPos and endPos. Initially, you are standing at position startPos on an infinite number line. With one step, you can move either one position to the left, or one position to the right.
Given a positive integer k, return the number of different ways to reach the position endPos starting from startPos, such that you perform exactly k steps. Since the answer may be very large, return it modulo 109 + 7.
Two ways are considered different if the order of the steps made is not exactly the same.
Note that the number line includes negative integers.
Example 1:
Input: startPos = 1, endPos = 2, k = 3
Output: 3
Explanation: We can reach position 2 from 1 in exactly 3 steps in three ways:
- 1 - 2 - 3 - 2.
- 1 - 2 - 1 - 2.
- 1 - 0 - 1 - 2.
It can be proven that no other way is possible, so we return 3.
Example 2:
Input: startPos = 2, endPos = 5, k = 10
Output: 0
Explanation: It is impossible to reach position 5 from position 2 in exactly 10 steps.
#codechef #coding #python #hackerrank #programming #java #computerscience #coder #code #competitiveprogramming #machinelearning #pythonprogramming #algorithms #cpp #javascript #hackerearth #webdeveloper #geeksforgeeks #codinglife #leetcode #c #codeforces #engineering #codingmemes #programmer #hacker #programmingmemes #topcoder #webdevelopment #bhfyp #DSAwithKunal
Problem link :
leetcode.com/problems/number-of-ways-to-reach-a-position-after-exactly-k-steps/
Complete Java + DSA + Interview Preparation + CP Course
czcams.com/play/PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ.html
Hi, thanks for watching our video about Arrays in Java
In this video we’ll walk you through:
- Brute Force
- Efficient approach
- Solution Code
TIMESTAMPS
Intro
Explanation begins
IDE solution
ABOUT OUR CHANNEL
Our channel is all about Programming. We cover lots of cool stuff such as solution to problems, concept explanation and tricks to master CP
Check out our channel here:
czcams.com/channels/qtYay7YwH8JdZxDqpVEPvg.html
Don’t forget to subscribe!
CHECK OUT OUR OTHER Playlists
GeeksforGeeks playlist:
czcams.com/play/PLDaU_TBYXoirv-848r81oHLSArcBrjIe7.html
Complete C++ Course playlist:
czcams.com/play/PLDaU_TBYXoio9L1qRpTrtzK9JJAwFLMSj.html
CodeChef Playlist:
czcams.com/play/PLDaU_TBYXoip_JFIo0U-Nl2dNA_ZMsd2z.html
HackerRank playlist:
czcams.com/play/PLDaU_TBYXoirMjgzW59T_XMyT5yRZ7ht_.html
LeetCode problems
czcams.com/play/PLDaU_TBYXoirsirbg6feNCKk3oPRn6M7w.html
FIND US AT
www.waadanibhao.wordpress.com
GET IN TOUCH
Contact us on hopesalivenow@gmail.com
2400. Number of Ways to Reach a Position After Exactly k Steps
Medium
86
35
Add to List
Share
You are given two positive integers startPos and endPos. Initially, you are standing at position startPos on an infinite number line. With one step, you can move either one position to the left, or one position to the right.
Given a positive integer k, return the number of different ways to reach the position endPos starting from startPos, such that you perform exactly k steps. Since the answer may be very large, return it modulo 109 + 7.
Two ways are considered different if the order of the steps made is not exactly the same.
Note that the number line includes negative integers.
Example 1:
Input: startPos = 1, endPos = 2, k = 3
Output: 3
Explanation: We can reach position 2 from 1 in exactly 3 steps in three ways:
- 1 - 2 - 3 - 2.
- 1 - 2 - 1 - 2.
- 1 - 0 - 1 - 2.
It can be proven that no other way is possible, so we return 3.
Example 2:
Input: startPos = 2, endPos = 5, k = 10
Output: 0
Explanation: It is impossible to reach position 5 from position 2 in exactly 10 steps.
#codechef #coding #python #hackerrank #programming #java #computerscience #coder #code #competitiveprogramming #machinelearning #pythonprogramming #algorithms #cpp #javascript #hackerearth #webdeveloper #geeksforgeeks #codinglife #leetcode #c #codeforces #engineering #codingmemes #programmer #hacker #programmingmemes #topcoder #webdevelopment #bhfyp #DSAwithKunal
zhlédnutí: 612
Video
2399 Check Distances Between Same Letters | Zero to FAANG Kunal | Assignment Solution | Leetcode
zhlédnutí 596Před rokem
2399 Check Distances Between Same Letters | Zero to FAANG Kunal | Assignment Solution | Leetcode | Shapnesh Tiwari Problem link : leetcode.com/contest/weekly-contest-309/problems/check-distances-between-same-letters/ Complete Java DSA Interview Preparation CP Course czcams.com/play/PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ.html Hi, thanks for watching our video about Arrays in Java In this video we’ll...
2375 Construct Smallest Number From DI String | Zero to FAANG | Striver SDE Sheet | Shapnesh | WE2
zhlédnutí 381Před rokem
2375 Construct Smallest Number From DI String | Zero to FAANG | Striver SDE Sheet | Shapnesh | WE2 @Striver Problem link : leetcode.com/problems/construct-smallest-number-from-di-string/ Hi, thanks for watching our video about Strings In this video we’ll walk you through: - Brute Force - Efficient approach - Solution Code TIMESTAMPS Intro Explanation begins IDE solution ABOUT OUR CHANNEL Our ch...
2315 Count Asterisks | Zero to FAANG | Weekly 296 | Striver SDE Sheet | Shapnesh | WE2
zhlédnutí 748Před 2 lety
2315 Count Asterisks | Zero to FAANG | Weekly 296 | Striver SDE Sheet | Shapnesh | WE2 @Striver Problem link : leetcode.com/problems/count-asterisks/ Hi, thanks for watching our video about Strings In this video we’ll walk you through: - Brute Force - Efficient approach - Solution Code TIMESTAMPS Intro Explanation begins IDE solution ABOUT OUR CHANNEL Our channel is all about Programming. We co...
2295 Replace Elements in an Array | Zero to FAANG | Weekly 296 | Striver SDE Sheet | Shapnesh | WE2
zhlédnutí 666Před 2 lety
2293 Min Max Game | Zero to FAANG | Weekly 294 | Leetcode | Striver SDE Sheet | Shapnesh | WE2 @striver_79 Problem link : leetcode.com/problems/replace-elements-in-an-array/ Hi, thanks for watching our video about Arrays In this video we’ll walk you through: - Brute Force - Efficient approach - Solution Code TIMESTAMPS Intro Explanation begins IDE solution ABOUT OUR CHANNEL Our channel is all a...
2294 Partition Array Such That Maximum Difference Is K | Zero to FAANG | Weekly 296 | Striver | WE2
zhlédnutí 587Před 2 lety
2293 Min Max Game | Zero to FAANG | Weekly 294 | Leetcode | Striver SDE Sheet | Shapnesh | WE2 Problem link : leetcode.com/problems/partition-array-such-that-maximum-difference-is-k/ Hi, thanks for watching our video about Arrays In this video we’ll walk you through: - Brute Force - Efficient approach - Solution Code TIMESTAMPS Intro Explanation begins IDE solution ABOUT OUR CHANNEL Our channel...
2293 Min Max Game | Zero to FAANG | Weekly 296 | Leetcode | Striver SDE Sheet | Shapnesh | WE2
zhlédnutí 470Před 2 lety
2293 Min Max Game | Zero to FAANG | Weekly 294 | Leetcode | Striver SDE Sheet | Shapnesh | WE2 Problem link : leetcode.com/problems/min-max-game/ Hi, thanks for watching our video about Arrays In this video we’ll walk you through: - Brute Force - Efficient approach - Solution Code TIMESTAMPS Intro Explanation begins IDE solution ABOUT OUR CHANNEL Our channel is all about Programming. We cover l...
2280 Minimum Lines to Represent a Line Chart | Zero to FAANG | Weekly 294 | Leetcode | WE2
zhlédnutí 232Před 2 lety
2280 Minimum Lines to Represent a Line Chart | Zero to FAANG | Weekly 294 | Leetcode | WE2 Problem link : leetcode.com/problems/minimum-lines-to-represent-a-line-chart/ Hi, thanks for watching our video about 2D Arrays In this video we’ll walk you through: - Brute Force - Efficient approach - Solution Code TIMESTAMPS Intro Explanation begins IDE solution ABOUT OUR CHANNEL Our channel is all abo...
2279 Maximum Bags With Full Capacity of Rocks | Zero to FAANG | Weekly 294 | Leetcode | Striver
zhlédnutí 936Před 2 lety
2279 Maximum Bags With Full Capacity of Rocks | Zero to FAANG | Weekly 294 | Leetcode | Striver Problem link : leetcode.com/problems/maximum-bags-with-full-capacity-of-rocks/ Hi, thanks for watching our video about Strings In this video we’ll walk you through: - Brute Force - Efficient approach - Solution Code TIMESTAMPS Intro Explanation begins IDE solution ABOUT OUR CHANNEL Our channel is all...
2278 Percentage of Letter in String | Zero to FAANG | Weekly 294 | Leetcode | Striver | WE2
zhlédnutí 343Před 2 lety
2278 Percentage of Letter in String | Zero to FAANG | Weekly 294 | Leetcode | Striver | WE2 Problem link : leetcode.com/problems/percentage-of-letter-in-string/ Hi, thanks for watching our video about Strings In this video we’ll walk you through: - Brute Force - Efficient approach - Solution Code TIMESTAMPS Intro Explanation begins IDE solution ABOUT OUR CHANNEL Our channel is all about Program...
2270 Number of Ways to Split Array | Zero to FAANG | Solution | Leetcode | Striver | WE2
zhlédnutí 592Před 2 lety
2270 Number of Ways to Split Array | Zero to FAANG | Solution | Leetcode | Striver | WE2 Problem link : leetcode.com/problems/number-of-ways-to-split-array/ Hi, thanks for watching our video about Arrays In this video we’ll walk you through: - Brute Force - Efficient approach - Solution Code TIMESTAMPS Intro Explanation begins IDE solution ABOUT OUR CHANNEL Our channel is all about Programming....
2269 Find the K Beauty of a Number | Zero to FAANG | Solution | Leetcode | Striver | WE2
zhlédnutí 833Před 2 lety
2269 Find the K Beauty of a Number | Zero to FAANG | Solution | Leetcode | Striver | WE2 Problem link : leetcode.com/problems/find-the-k-beauty-of-a-number/ Hi, thanks for watching our video about Arrays In this video we’ll walk you through: - Brute Force - Efficient approach - Solution Code TIMESTAMPS Intro Explanation begins IDE solution ABOUT OUR CHANNEL Our channel is all about Programming....
2265 Count Nodes Equal to Average of Subtree | Zero to FAANG | Solution | Leetcode | Striver | WE2
zhlédnutí 2KPřed 2 lety
2265 Count Nodes Equal to Average of Subtree | Zero to FAANG | Solution | Leetcode | Striver | WE2 Problem link : leetcode.com/problems/count-nodes-equal-to-average-of-subtree/ Hi, thanks for watching our video about Trees In this video we’ll walk you through: - Brute Force - Efficient approach - Solution Code TIMESTAMPS Intro Explanation begins IDE solution ABOUT OUR CHANNEL Our channel is all...
2264 Largest 3 Same Digit Number in String | Zero to FAANG | Solution | Leetcode | Striver | WE2
zhlédnutí 908Před 2 lety
2264 Largest 3 Same Digit Number in String | Zero to FAANG | Solution | Leetcode | Striver | WE2 Problem link : leetcode.com/problems/largest-3-same-digit-number-in-string/ Hi, thanks for watching our video about Arrays In this video we’ll walk you through: - Brute Force - Efficient approach - Solution Code TIMESTAMPS Intro Explanation begins IDE solution ABOUT OUR CHANNEL Our channel is all ab...
2256 Minimum Average Difference | Zero to FAANG | Assignment Solution | Leetcode | Striver | WE2
zhlédnutí 1,1KPřed 2 lety
2256 Minimum Average Difference | Zero to FAANG | Assignment Solution | Leetcode | Striver | WE2 Problem link : leetcode.com/problems/minimum-average-difference/ Hi, thanks for watching our video about Arrays In this video we’ll walk you through: - Brute Force - Efficient approach - Solution Code TIMESTAMPS Intro Explanation begins IDE solution ABOUT OUR CHANNEL Our channel is all about Program...
2255 Count Prefixes of a Given String | Zero to FAANG | Assignment Solution | Leetcode | Striver
zhlédnutí 817Před 2 lety
2255 Count Prefixes of a Given String | Zero to FAANG | Assignment Solution | Leetcode | Striver
2248. Intersection of Multiple Arrays | Zero to FAANG | Assignment Solution | Leetcode | Striver
zhlédnutí 796Před 2 lety
2248. Intersection of Multiple Arrays | Zero to FAANG | Assignment Solution | Leetcode | Striver
682 Baseball Game | Zero to FAANG | Assignment Solution | Leetcode | Striver | WE2 | Shapnesh
zhlédnutí 346Před 2 lety
682 Baseball Game | Zero to FAANG | Assignment Solution | Leetcode | Striver | WE2 | Shapnesh
215 Kth Largest Element in an Array | 703. Kth Largest Element in a Stream | Priority Queue | WE2
zhlédnutí 178Před 2 lety
215 Kth Largest Element in an Array | 703. Kth Largest Element in a Stream | Priority Queue | WE2
454 4Sum II | Zero to FAANG | Assignment Solution | Leetcode | Shapnesh | Programmers Zone
zhlédnutí 244Před 2 lety
454 4Sum II | Zero to FAANG | Assignment Solution | Leetcode | Shapnesh | Programmers Zone
Good Weather(GOODWEAT) | CodeChef Practice(Beginner) | CodeChef | Complete Solutions
zhlédnutí 556Před 2 lety
Good Weather(GOODWEAT) | CodeChef Practice(Beginner) | CodeChef | Complete Solutions
1346 Check If N and Its Double Exist | Zero to FAANG | Assignment Solution | Leetcode | Shapnesh
zhlédnutí 2,8KPřed 2 lety
1346 Check If N and Its Double Exist | Zero to FAANG | Assignment Solution | Leetcode | Shapnesh
1089. Duplicate Zeros | Zero to FAANG Kunal | Assignment Solution | Leetcode | Shapnesh
zhlédnutí 3,3KPřed 2 lety
1089. Duplicate Zeros | Zero to FAANG Kunal | Assignment Solution | Leetcode | Shapnesh
Equal Or Not Equal | CodeForces | Educational Codeforces Round 119 (Rated for Div. 2) | Shapnesh
zhlédnutí 332Před 2 lety
Equal Or Not Equal | CodeForces | Educational Codeforces Round 119 (Rated for Div. 2) | Shapnesh
Equal Coins (EQUALCOIN) | Codechef Long November | November Challenge 2021 Division 3
zhlédnutí 4,1KPřed 2 lety
Equal Coins (EQUALCOIN) | Codechef Long November | November Challenge 2021 Division 3
Which Fuel is Cheaper (CHEAPFUEL) | Codechef Long November | November Challenge 2021 Division 3
zhlédnutí 2,6KPřed 2 lety
Which Fuel is Cheaper (CHEAPFUEL) | Codechef Long November | November Challenge 2021 Division 3
DSA | Binary Search | lecture 02 | Best explanation of Binary Search in arrays
zhlédnutí 283Před 2 lety
DSA | Binary Search | lecture 02 | Best explanation of Binary Search in arrays
DSA | linear Search | lecture 01 | Best explanation of linear Search in arrays
zhlédnutí 136Před 2 lety
DSA | linear Search | lecture 01 | Best explanation of linear Search in arrays
2011 Final Value of Variable After Performing Operations | Zero to FAANG Kunal | Leetcode | Shapnesh
zhlédnutí 4,4KPřed 2 lety
2011 Final Value of Variable After Performing Operations | Zero to FAANG Kunal | Leetcode | Shapnesh
Longest AND Subarray (ANDSUBAR) | Codechef Long October | October Challenge 2021 Division 3 (Rated)
zhlédnutí 7KPřed 2 lety
Longest AND Subarray (ANDSUBAR) | Codechef Long October | October Challenge 2021 Division 3 (Rated)
kunal and you are doing an excellent job ! Thank You <3
Leet code ki easy solutions bhi medium level ke hai
It seema to be little difficult for beginners who have directly come for solving questions after understanding the concept of array.😢😢😢😢😢. logic of solving this Question didn't strike in my mind..
Nice Explanation sir..
Great explnation man!
thanks,btw nice explanation ✔✔❣❣
class Solution { public: int finalValueAfterOperations(vector<string>& operations) { int x = 0; int n = operations.size(); for (int i = 0;i <n;i++){ if(operations[i] == "++X" || operations[i] == "X++"){ x++; } else{ x--; } } return x; } };
good work bro !!!!!!!!!!!
pen paper leh le bhai usmai humlogo ko better dikhaga
Nice thanks
Compilation Error ./Solution.cpp: In function 'void iter(std::vector<int>::iterator, std::vector<int>::iterator)': ./Solution.cpp:19:22: error: 'it' was not declared in this scope for(it1;it1!=it2;it++)
NICE SUPER EXCELLENT MOTIVATED
use LinkedList to improve the time complexity as insertion is O(1) in LinkedList and O(n) in array list
why the time complexity is not o(n*m)
why my code is not running var twoSum = function(nums, target) { for(let i=0;i<nums.length;i++) { for(j=i+1;j<nums.length;j++) { if((nums[i]+nums[j])==target) { console.log("the indices where target matched is="); console.log("["+i+","+j+"]"); } } } };]
run the first loop till nums.length - 1
iska logic kaise banaya bhai? mai kaise aise sochna seekh pau? ye to mai soch hi nhi skta tha kbhi to
bro help why its not passing all test case? it tried to solve using binary search import java.util.Arrays; class Solution { public boolean checkIfExist(int[] arr) { Arrays.sort(arr); for (int i = 0; i < arr.length; i++) { if (binarySearch(arr, arr[i], i)) { return true; } } return false; } private boolean binarySearch(int[] arr, int target, int i) { int start = 0; int end = arr.length - 1; while (start <=end) { int mid = start + (end - start) / 2; if ((mid != i)&&(arr[mid]/2 == target )) { return true; } else if (arr[mid] < target && mid!=0) { start = mid + 1; } else { end = mid - 1; } } return false; } }
nums=[0,2,1,5,3,4] result1=[] for i in range(len(nums)): result=nums[nums[i]] result1.append(result) print(result1)
thank u brother ,
Thank you bro
IN while loop, it should be greater than or equal to 1
nice explanation
Thankyou man!
Since it is given that 0<=nums[i]<=n, there is need to do mod with n.
Bro 1920 ???
Loved this explanation and concept. Thank you
how did you come up with this approach? I mean the thought process
2:47 bich wala flip nhi krenge agar 3*3 ki matrix hui but agar 4*4 ki matrix hui toh kyuki agr 4*4 Me pura flip krenge toh bech me pura flip hoga na. Im bit confused here
spiral matrix 3 wala solve kro plez............
bhai spiral matrix 3 ispe video banao plez
tysm for the explanation
thanks bhaiya
Thank you brother
Excellent explanation!
improve handwriting please
Thanks brother
In question it is written that we have to return the first occurrence of the max year which will be not the case with brute force solution
yrr code linke de dena chaey tha tb hm c++ me convert kr lete
he is confused as well and making us confusee
Brilliant🎉
why u placed the king at( 3,3 )coordinate only
Nice explanation
Great explanation
👏🔥 Kudos to you for this amazing video! Keep up the fantastic work! 🚀💡
guess fn kaha gaya ? gemd me dal liye kya guess fn
Na bhai wo internally implemented tha
bro you should use a black pen instead of red
what is math.log10()?? how does it works?
Good explanation bro bs ye mat[n-1-i] wla logic nhi samajh aaya ? Bata do koi agar janta hai toh
nice explain sir😊
worst explaination ever