🔥 Subscribe to coding75 Pro for Live Classes, 1:1 Mentorship Sessions: coding75.com/pro ✅ Live DSA Classes ✅ Codeforces, Codechef, Leetcode Live Discussion ✅ 1:1 Mock Interviews ✅ 1:1 Mentorship Sessions ✅ 1:1 Resume Review ✅ Live Weekly Project Building Sessions ✅ Live CS Fundamental Classes In case of any queries regarding coding75, WhatsApp us here: wa.me/message/TPN76XLWVOWDB1
at 43:51 you said we can go from ind to ind2 which is not true because we want to maximize the health that we are subtracting from the predix sum... so we need to check for both ind and ind2 as extremes and take the maximum of them
I HAVE A DOUBT IN DOUBLE TROUBLE PROBLEM: jo first case h,jisme ek baal ko right ki taraf throw kr rhe h aur end wali ball ko left mein throw kr rhe h us case mein aisa bhi toh ho skta h ki end mein jb dono balls ruk jaye aur unke beech ka gap
hey abhinav, ive a doubt in question c, there we are checking for every elemnt , but is there any optimal to way to directly choose a number from an array which we can change into 1 or k. Can we do like this-> we'll choose that inex from array which gives the minimum sum of adj diff, and simply we'll replace it with the 1 or k by checking wehich is optimal and calculate the maximum? Please correct me if im wong
Why to check again the entire sequence again, can't we just check the remaining values which come ahead of bombing area using the build prefix till now. Plz can you tell what's wrong in my code: static void solve(){ int n = i(); int k = i(); long[] pos = inputL(n); long[] h = inputL(n); long prev = 0; int i = 0; while(i < n && pos[i] - prev > h[i]){ prev += h[i]; i++; } if(i == n){ pl("YES"); return; } long bombArea = pos[i] + 1L*k*2; while(i < n && pos[i] h[i]){ prev += h[i]; i++; } if(i == n){ pl("YES"); } else { pl("NO"); } }
#include using namespace std; int main() { //Observations: //1.Alice has N magical balls on x-axis. //2.ith ball at Xi has Pi power. //3.the positions are in ascending order. //4.Initially no ball is activated. //5.Alice can do the following operation at most twice. //(i) choose an index i such that ball i is not visited. //(ii) mark it visited and choose a direction for it either left or right. //6.When ball i is marked visited it will move Pi steps in choosen direction. //7.While moving if it strikes with another ball j, ith ball will disappear and the following will happen //(i) If j was visited the process ends. //(ii) else j is marked visited and moves in the same direction as i. //8.If it does't strikeit will stop after Pi steps. //9.We need to return if it is possible to mark every ball visited.
int t; cin>>t; while(t--){ int n; cin>>n; vectorX(n+1); vectorP(n+1); cin>>X; cin>>P; vectorvisited; visited[0]=true; int count=2; //Algorithm: //we need to store the range for each ball as [Xi-Pi,Xi+Pi]. //We need to choose the index which is previously not visited and covers maximum range which contain different ball positions. //After choosing the maximum we need to choose that index i. //And mark all the balls of X in the range as visited along with the ith ball, and decrement count. //Repeat the process untill count==0. //After this check if all the balls are visited if yes return true else false.
//ith ball strikes jth ball if number of units moved by i (Pi) makes the position of it >= position of j.
} } is there any mistake in the Algorithm I mentioned here??
where my logic failing?please reply anyine for _ in range(int(input())): n,k=map(int,input().split()) X=list(map(int,input().split())) p=list(map(int,input().split())) f=0 i=0 time=0 use=0 while i=p[i]: time+=p[i] i+=1 elif use==0: moveto=X[i]+2*k while i
//why this code has been not worked #include using namespace std; #define int long long void solve(){ int n,k; cin>>n>>k; vector v(n); for(auto &i:v) cin>>i; if(n == 1){cout
🔥 Subscribe to coding75 Pro for Live Classes, 1:1 Mentorship Sessions: coding75.com/pro
✅ Live DSA Classes
✅ Codeforces, Codechef, Leetcode Live Discussion
✅ 1:1 Mock Interviews
✅ 1:1 Mentorship Sessions
✅ 1:1 Resume Review
✅ Live Weekly Project Building Sessions
✅ Live CS Fundamental Classes
In case of any queries regarding coding75, WhatsApp us here: wa.me/message/TPN76XLWVOWDB1
SpeedRun solution was too good, thank you for the video Sir.
It is wrong solution
@@HarshKumar-xw5nn what is wrong in the solution , is there any edge case we are missing ?
4 1
1000 10008 1010 1015
1000 10 10 10
Isn't it better to just remove the first moster rather than first loosing moster?
at 43:51 you said we can go from ind to ind2 which is not true because we want to maximize the health that we are subtracting from the predix sum... so we need to check for both ind and ind2 as extremes and take the maximum of them
we have to take all the i from 0 to index such that it leaves a max impact and then we will take maximum of them
Can you give a testcase where ind to ind2 fails
bhai bhi nahi hai behen bhi nahi hai😂😂😂
😂😂😂😂😂😂
I HAVE A DOUBT IN DOUBLE TROUBLE PROBLEM:
jo first case h,jisme ek baal ko right ki taraf throw kr rhe h aur end wali ball ko left mein throw kr rhe h
us case mein aisa bhi toh ho skta h ki end mein jb dono balls ruk jaye aur unke beech ka gap
Brilliant!!! very well explained
Bro your code failed on this test case, your code is outputting "NO"" but the answer should be "YES". For problem speedrun
1
3 1
10 13 16
10 4 7
thank youuu . Now I can sleep peacefully .I have been thinking about the testcase that causes my code to fail .Your testcase helped me .!!!
iska he wait tha
Can anyone Elaborate the Idea of Double Trouble with DFS?
hey abhinav, ive a doubt in question c, there we are checking for every elemnt , but is there any optimal to way to directly choose a number from an array which we can change into 1 or k. Can we do like this-> we'll choose that inex from array which gives the minimum sum of adj diff, and simply we'll replace it with the 1 or k by checking wehich is optimal and calculate the maximum? Please correct me if im wong
I also thought like this during the contest...but later saw the constraints & saw that checking each & every element would be feasible as N
@@priyanshkumar17 right!
alice bhai hi hai shayad ...
Why 2k on one side in speedrun question??
Why to check again the entire sequence again, can't we just check the remaining values which come ahead of bombing area using the build prefix till now. Plz can you tell what's wrong in my code:
static void solve(){
int n = i();
int k = i();
long[] pos = inputL(n);
long[] h = inputL(n);
long prev = 0;
int i = 0;
while(i < n && pos[i] - prev > h[i]){
prev += h[i];
i++;
}
if(i == n){
pl("YES");
return;
}
long bombArea = pos[i] + 1L*k*2;
while(i < n && pos[i] h[i]){
prev += h[i];
i++;
}
if(i == n){
pl("YES");
} else {
pl("NO");
}
}
Double trouble very easy code and approach 🐷🐷🐷
void solve() {
int n;
cin>>n;
vectorv(n);
vectorp(n);
loop(i,n)cin>>v[i];
loop(i,n)cin>>p[i];
int left1=0;
int right1=n-1;
int left2=0;
int right2=n-1;
for(int i=0;i=v[i+1]){
left1++;
}
else{
break;
}
}
for(int i = n-1;i>0;i--){
if(abs(v[i]-p[i])=rt){
py;
}
else{
pn;
}
}
#include
using namespace std;
int main() {
//Observations:
//1.Alice has N magical balls on x-axis.
//2.ith ball at Xi has Pi power.
//3.the positions are in ascending order.
//4.Initially no ball is activated.
//5.Alice can do the following operation at most twice.
//(i) choose an index i such that ball i is not visited.
//(ii) mark it visited and choose a direction for it either left or right.
//6.When ball i is marked visited it will move Pi steps in choosen direction.
//7.While moving if it strikes with another ball j, ith ball will disappear and the following will happen
//(i) If j was visited the process ends.
//(ii) else j is marked visited and moves in the same direction as i.
//8.If it does't strikeit will stop after Pi steps.
//9.We need to return if it is possible to mark every ball visited.
int t;
cin>>t;
while(t--){
int n;
cin>>n;
vectorX(n+1);
vectorP(n+1);
cin>>X;
cin>>P;
vectorvisited;
visited[0]=true;
int count=2;
//Algorithm:
//we need to store the range for each ball as [Xi-Pi,Xi+Pi].
//We need to choose the index which is previously not visited and covers maximum range which contain different ball positions.
//After choosing the maximum we need to choose that index i.
//And mark all the balls of X in the range as visited along with the ith ball, and decrement count.
//Repeat the process untill count==0.
//After this check if all the balls are visited if yes return true else false.
//ith ball strikes jth ball if number of units moved by i (Pi) makes the position of it >= position of j.
}
}
is there any mistake in the Algorithm I mentioned here??
how 2*k come?
That voilet color Advertisment is disturbing us. Please remove it and find some other neat way to put in some other place. Its really disturbing
where my logic failing?please reply anyine
for _ in range(int(input())):
n,k=map(int,input().split())
X=list(map(int,input().split()))
p=list(map(int,input().split()))
f=0
i=0
time=0
use=0
while i=p[i]:
time+=p[i]
i+=1
elif use==0:
moveto=X[i]+2*k
while i
JOKES TO HAI GANDE 😂 BUT EXPLAINATION ACHE HAI SIR
//why this code has been not worked
#include
using namespace std;
#define int long long
void solve(){
int n,k; cin>>n>>k;
vector v(n); for(auto &i:v) cin>>i;
if(n == 1){cout