@@YashwanthsaiCh The most efficient Dp solution had time complexity of O(n^2) and the constraint was 10^5 so it would give tle that's why it was useless to apply DP there.
@@VirajChandra In the contest itself i'm able figure out it's a BS problem but not able to write Checker function. After watching this also not able to understand. I tried several videos but can't figure it out. eg:- [8, 0, 4] d=2 sort [0, 4, 8] range becomes [[0, 2], [4, 6], [8, 10]] Let say mid = 1 Which numbers should be taken from the range to make minimum abs difference to be mid=1.
one more observation on the last one, the dp array can be 2d. since any nth turn cant be played by both a and b, just dp on cur, mask would also suffice
@VirajChandra why did you push knight's position coordinates in positions 2d vector? Like we can directly call the recursive function from the knight's position without adding it in positions vector???
@@VirajChandra sorry sir i still didn't understand. Like even in leetcode hint section they have told to consider the knight's original position as another pawn. why is it so? As for preprocess function we are actually just using the constraints given in the problem and aren't using any info about positions of pawns.
@@Authenticbharatiya So in the preprocess function, we are trying to find the minimum moves required to go from each point to each point. To do this, we need in the positions array, and in that we also need the knight's position to be added so that in the preprocess function it gets treated as a point and we are able to calculate minimum moves from it to other points.
int dist[50][50][50][50]; int dx[]={1,2,2,1,-1,-2,-2,-1}; int dy[]={-2,-1,1,2,2,1,-1,-2}; class Solution { public: void calcdistance(int kx, int ky) { queue q; q.push({0,{kx,ky}}); dist[kx][ky][kx][ky]=0; while(q.size()) { int d = q.front().first; int x = q.front().second.first; int y = q.front().second.second; q.pop(); for(int i=0;i=0 and newx=0 and newy
Please fill the feedback form for PCD: forms.gle/qGQqEaVYeAvR7sZr8
Only one request from this channel coordinators....plzzzzzz keep this guy only for leetcode discussion...it my humble request to you guys
I don’t comment mostly but the way 4th question was explained man too great. Best explanation
Explanation to the 4th question is simple Amazing. The best explanation one can get from a hard problem. Thank you so much!
Better than other teachers explanation on this channel!!
+1
+1
Best explanation 👌
Nice Explanation .
Great explanation. Thank you.
Applied DP on 3rd and stuck on test case 601
Same
Everyone fell into the same trap. I wonder how one could come up with greedy solution
Read the constraints and left it at once, cauz dp was not gonna work😢
@@he-harshedits361 how did you know dp is not going to work after reading constraints?
@@YashwanthsaiCh The most efficient Dp solution had time complexity of O(n^2) and the constraint was 10^5 so it would give tle that's why it was useless to apply DP there.
wow man, what a explaination
q2 explanation ? Wasnt explained well. Take it as a constructive criticism.
Hi, what seemed missing?
@@VirajChandra In the contest itself i'm able figure out it's a BS problem but not able to write Checker function. After watching this also not able to understand. I tried several videos but can't figure it out.
eg:- [8, 0, 4] d=2
sort [0, 4, 8]
range becomes [[0, 2], [4, 6], [8, 10]] Let say mid = 1 Which numbers should be taken from the range to make minimum abs difference to be mid=1.
@@khalidalam980 You dont have to make diff exactly equal to one it might be >=1 as well
one more observation on the last one, the dp array can be 2d. since any nth turn cant be played by both a and b, just dp on cur, mask would also suffice
Correct! This is an optimisation on Alice Bob game problems.
Great explanation
viraj bhaiya I am very weak at rerooting dp, can you explain some of lc problems involving rerooting because your explanation is something else.
Nice explanation
Great explanation on problem 2.Need socials of the guy explaining.. why are they not posted in the description? Not even a name? lol
Hi, my is Viraj. It’s in the title.😅
Brilliant viraj
@VirajChandra why did you push knight's position coordinates in positions 2d vector? Like we can directly call the recursive function from the knight's position without adding it in positions vector???
I’m using that position in the preprocess function.
@@VirajChandra sorry sir i still didn't understand. Like even in leetcode hint section they have told to consider the knight's original position as another pawn. why is it so? As for preprocess function we are actually just using the constraints given in the problem and aren't using any info about positions of pawns.
@@Authenticbharatiya So in the preprocess function, we are trying to find the minimum moves required to go from each point to each point. To do this, we need in the positions array, and in that we also need the knight's position to be added so that in the preprocess function it gets treated as a point and we are able to calculate minimum moves from it to other points.
@@VirajChandra understood sir. thanks a lot!!!
int dist[50][50][50][50];
int dx[]={1,2,2,1,-1,-2,-2,-1};
int dy[]={-2,-1,1,2,2,1,-1,-2};
class Solution {
public:
void calcdistance(int kx, int ky) {
queue q;
q.push({0,{kx,ky}});
dist[kx][ky][kx][ky]=0;
while(q.size()) {
int d = q.front().first;
int x = q.front().second.first;
int y = q.front().second.second;
q.pop();
for(int i=0;i=0 and newx=0 and newy
Can you send submission link?
q2😥
?
why do we need a mask ? can't we simply use a visited array ?
It would be not viable to maintain visited array as a state
Can we count elements greater than nums[0]until n-1 will that workk?? (Question 3)
Can you give some more details of your idea?
For example 4,5,3,8,9,5,5,2 his idea is taking 4,5,8,9.my idea is taking 4,5,8,9,5,5
I think you get a lower answer from this.
Very poor explanation for problem B
Hi! What was missing?
@@VirajChandra It was Good!