Пікірлер
@harshitkumar4129
@harshitkumar4129 10 сағат бұрын
E constraints were too tight. This complexity N*M is not expected for E.
@AppMaruf
@AppMaruf 14 сағат бұрын
Can u explain why we will use c++ 20? in A
@pr_inv8
@pr_inv8 19 сағат бұрын
can u explain this in case of k = 10 ^ 18 its answer = 1000000001000000000 why not its 1000000000099999999??
@GauravDuseja-t6q
@GauravDuseja-t6q 21 сағат бұрын
How base case for len=1,k is 1 for 0,k suppose [0,3]-->[3,3],[2,3],[4,3] there are 3 possibility coming
@moopoo-h2u
@moopoo-h2u 23 сағат бұрын
When Update problem F my bro, i really wanna solve that
@danielhack096
@danielhack096 Күн бұрын
w
@danielhack096
@danielhack096 Күн бұрын
g
@harshalgupta3453
@harshalgupta3453 Күн бұрын
The algorithm for problem B is is giving wrong answer on 8 th test case in java: import java.util.*; public class State{ public static void main(String args[]) { Scanner scm=new Scanner(System.in); int t=scm.nextInt(); for(int a=1;a<=t;a++) { long k=scm.nextLong(); long low=1; long high=(long)4e18; long mid=0; if(k==1) { System.out.println(2); } else { long answer=0; while(low<=high) { mid=(low+high)/2; long ans=mid-(long)Math.floor(Math.sqrt(mid)); if(ans<k) { low=mid+1; } else { answer=mid; high=mid-1; } } System.out.println(answer); } } } } Can someone suggest why?
@colgate1602
@colgate1602 Күн бұрын
I am a c++ user but from I guess I think your Math.sqrt() function takes double for input, but you need long double for input, so you should use binary search for taking out the sqrt or check out if there is a function in java that takes long double for input. Similar thing happened to me where my sqrt() function didn't worked, so I had to use sqrtl() which is new to me
@harshalgupta3453
@harshalgupta3453 11 сағат бұрын
@@colgate1602 thanks buddy !!
@aditisingh-i8o
@aditisingh-i8o Күн бұрын
Using dfs on graphs in D gives MLE on test case 7
@gaurishbaliga3723
@gaurishbaliga3723 Күн бұрын
You need to optimise adding edges. Like in my solution code, if you replace DSU.unionset by the push_back we do for graphs, it should work
@VasuBhalani
@VasuBhalani Күн бұрын
please help me same code in c++ why not run in java. import java.util.Scanner; public class problema { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- != 0) { long k = sc.nextLong(); long maxans = (4 * (long) Math.pow(10, 18)) ; long low = 1L; long high = maxans; long myans = 0L; while (low <= high) { long mid = ( low) + ((high-low) / 2); double ans = Math.sqrt(mid); long my = (mid - (long)ans); if (my < k) { low = mid + 1; } else { myans = mid; high = mid - 1; } } System.out.println(myans); } sc.close(); } } please help me give wrong answer in java same code. why giving wrong answer in testcases 8 .
@lakshaydhiman4056
@lakshaydhiman4056 Күн бұрын
Nice explanation sir, i have never solved problems on probability and modular inverse. Solution was a great help
@ishanmusic677
@ishanmusic677 Күн бұрын
use long long and submit in c++20 (if anyone getting tle)
@AppMaruf
@AppMaruf 14 сағат бұрын
Can u explain why we will use c++ 20?
@ishanmusic677
@ishanmusic677 14 сағат бұрын
@@AppMaruf im not sure but ig c++20 comes up with some optimization in stl and better run time behaviour, so due to that the same solution got accepted which is giving tle in c++17
@mahedihasananik254
@mahedihasananik254 2 күн бұрын
Why we are still looking for mid in the else statement after setting answer equal to mid? In the else statement why we are still doing r=mid-1 after setting the answer equal to mid? In the problem B.
@rounakpatra3406
@rounakpatra3406 Күн бұрын
Because we have to minimize our n There can be multiple n for which exactly k bulbs will light up and we have to choose the minimum no of bulbs hence once we get an possible n we are storing it in answer and looking for smaller n to check wether can we achieve the desired state of exactly k bulbs that are on
@weeblyoverloaded3824
@weeblyoverloaded3824 Күн бұрын
we want to find the minimum answer, when our on > n that means we have a value which can be our answer but as we want the minimum value we will look on left side to find the least value
@Aryan_083
@Aryan_083 2 күн бұрын
problem A is giving tle in test 3 in java
@skipper_and
@skipper_and 19 сағат бұрын
yes, check codeforces editorials they do upload the codes.
@Artisto-E7
@Artisto-E7 2 күн бұрын
I just copy and paste your code(problem A). But it's getting TLE in 5th test case ?
@aniketgupta8903
@aniketgupta8903 2 күн бұрын
Yea, It's TLE, they are expecting O(n)
@GopalYadav-re5rm
@GopalYadav-re5rm Күн бұрын
Try submitting in c++ 20 it will work
@AppMaruf
@AppMaruf 14 сағат бұрын
@@GopalYadav-re5rm Can u explain why we will use c++ 20?
@viratjain8394
@viratjain8394 2 күн бұрын
what kind of question is b i mean similar question names?
@Aryan-lk5lh
@Aryan-lk5lh 2 күн бұрын
I already did 2nd queation within 1 hour but showed wrong on test case 8 even when it was completely right because of the reason that i was using C++ 20 compiler instead of C++17 🥲🥲🥲🥲🥲
@AppMaruf
@AppMaruf 2 күн бұрын
Can u explain the time complexity of A?
@balasubramania3280
@balasubramania3280 2 күн бұрын
Hey can you please add time stamps for A, B , C, D, E so that we navigate easily
@MikasaAckerman-v8o
@MikasaAckerman-v8o 2 күн бұрын
Very great explanation
@GopalYadav-re5rm
@GopalYadav-re5rm 2 күн бұрын
The first code is now giving tle on 5th test case UPDATE: Sorry guys I was submitting In c++ 17 which is getting tle whereas c++20 It is getting accepted no idea why
@tervicke487
@tervicke487 2 күн бұрын
i used similiar approach and got accepted , u might be be going wrong somewhere with the loop causing an infinite loop.
@mahadevpnair3196
@mahadevpnair3196 2 күн бұрын
@@tervicke487 Can you share your code? I am getting TLE on 5th too.
@gaurishbaliga3723
@gaurishbaliga3723 2 күн бұрын
Its probably because I have defined int as long long in my code and you haven’t causing an integer overflow
@mahadevpnair3196
@mahadevpnair3196 2 күн бұрын
@@gaurishbaliga3723 It's Time Limit Exception, not any other kind of error.
@gaurishbaliga3723
@gaurishbaliga3723 2 күн бұрын
@@mahadevpnair3196Do share your code, let me look into it
@frouMagician
@frouMagician 2 күн бұрын
your explanations are crisp and to the point! Love it
@Vegito-ew3gn
@Vegito-ew3gn 2 күн бұрын
Gaurish sir is lit🔥🔥
@MindMingle-x3j
@MindMingle-x3j 2 күн бұрын
hey ,where to practice mathematical question like 1st or 2nd one.
@ubabnameh
@ubabnameh 2 күн бұрын
past div 2 a,b questions
@sahil___jakhar
@sahil___jakhar 2 күн бұрын
IQ + previous mathematics Olympiad exp
@sujansinhthakor2314
@sujansinhthakor2314 Күн бұрын
search project euler hackerRank
@youtuberbro4258
@youtuberbro4258 Күн бұрын
Atcoder beginner contests
@universalcosmologist3675
@universalcosmologist3675 2 күн бұрын
it should be e1>=e2 for third problem as e1 is smallest endpoint greater than k and e2 is largest but less than k
@TLE_Eliminators
@TLE_Eliminators 2 күн бұрын
Please fill the feedback form for PCD: forms.gle/TamiaQyjCaXYobzP7
@vivek.tiwary
@vivek.tiwary 2 күн бұрын
Hey Priyansh, this series is amazing, could you add more here ? If possible could you cover leetcodes problems ?
@Abhay14
@Abhay14 2 күн бұрын
A- this give me TLE class Solution { public: string reverseNext(string temp){ string ans = ""; for(auto it : temp){ ans += ((it-'a' + 1) % 26) + 'a'; } return ans; } char kthCharacter(int k) { string word = "a"; for(int i=0; i<k; i++){ string temp = word; word += reverseNext(temp); } return word[k-1]; } }; first time got TLE in easy solution :)
@itzzRaghav
@itzzRaghav 2 күн бұрын
Your for loop inside kthCharacter() method has k iterations, and the size of word will double in each iteration. So if k is 30, then the size of the string word will become 2^30 which we can't store in a string. And k can be as large as 500, so this solution wouldn't work.
@TLE_Eliminators
@TLE_Eliminators 3 күн бұрын
Please fill the feedback form for PCD: forms.gle/htwvkSfiCyv62Lfn8
@nomanbinsafar3128
@nomanbinsafar3128 3 күн бұрын
such a good explanation for B!
@subhajyotisaha1020
@subhajyotisaha1020 3 күн бұрын
One can also use TRie for the prolem A.
@garv1202
@garv1202 3 күн бұрын
6:30 bro be like , chalega kse nahi , le submission p submission 😂😂
@sujansinhthakor2314
@sujansinhthakor2314 3 күн бұрын
explanation of task b was so clear
@rahulg1989
@rahulg1989 3 күн бұрын
Thankyou bhai Love your content, currently 600 rating, road to CM
@priyanshvatsal9791
@priyanshvatsal9791 3 күн бұрын
Problem C's solution is as good as it can be 😇 Step1 - Find solution range ( Best -- n , Worst -- 1 ) ( Height of decks ) Step2 - Iteration through range from best to worst - Construct the deck ( total_cards_in_all_decks, no_of_decks ) - Check its validity ( total_cards_in_all_decks >= minimum_cards_available && max_frequency_any_card_type <= no_of_decks ) - If valid, return
@pawanjindal7588
@pawanjindal7588 4 күн бұрын
why we have freq1[word1[0]-'a']++; as we have initialised s and e from 0?
@Rlxn5
@Rlxn5 4 күн бұрын
Good explanation for B ❤
@11aniketkumar
@11aniketkumar 4 күн бұрын
Problem B explanation was great! I didn't found anyone explaining so clearly except this video
@swadheen01
@swadheen01 3 күн бұрын
yes, i am also here for this one. and it is well explained.
@viratjain8394
@viratjain8394 2 күн бұрын
what kind of question is b i mean similar question names?
@11aniketkumar
@11aniketkumar 2 күн бұрын
Maybe combinatorics because i starting points and (n-i) ending points needs to be multiplied is a concept of combination and permutations. Try problems with terms like subset, subarray or subsequence.
@viratjain8394
@viratjain8394 Күн бұрын
@@11aniketkumar thank you bhai!! i will try to find out similar question
@NANUVALAADITHYA
@NANUVALAADITHYA 4 күн бұрын
Can u tell the date when TLE 12.0 will be open?
@yatharthgupta6468
@yatharthgupta6468 4 күн бұрын
can you explain why doesn't binary search works in c? I correctly implemented the check conditions however since i did by bs,i failed in later test cases
@pranavsuren9489
@pranavsuren9489 10 сағат бұрын
Same
@shashanktiwari6999
@shashanktiwari6999 4 күн бұрын
was contest difficult today or its me only who is feeling this😅
@ThePROestRedn99
@ThePROestRedn99 4 күн бұрын
It seemed difficult
@mradultiwari9864
@mradultiwari9864 4 күн бұрын
It is
@shashankvashishtha4454
@shashankvashishtha4454 4 күн бұрын
B's problem statement is extremely difficult for me to understand (very unclear)
@ThePROestRedn99
@ThePROestRedn99 4 күн бұрын
@@shashankvashishtha4454 fr ..... That's because of Ai ..... But still chat gpt was able to solve it in first try i checked
@shashankvashishtha4454
@shashankvashishtha4454 4 күн бұрын
@@ThePROestRedn99 seriously 😳
@TLE_Eliminators
@TLE_Eliminators 4 күн бұрын
Please fill the Feedback form for PCD: forms.gle/PMkxPXD9KoRd5vJr5
@satheeshbhukya9970
@satheeshbhukya9970 4 күн бұрын
Nice explanation sir
@tuighetmonsinh7869
@tuighetmonsinh7869 4 күн бұрын
thank you so much!
@PubgMerabeta
@PubgMerabeta 5 күн бұрын
In your C solution you also get WA just bcz of not taking letter in a variable name temp . But I don't understand why. Can you please tell why?
@ashutoshraj7171
@ashutoshraj7171 5 күн бұрын
D -> solution ( passed -with out tle ) void sol() { int n; cin>>n; int ans=0; vector<int>arr(n); for(auto &it:arr) cin>>it; vector<int>str(1<<20,0); for(int i=0;i<n;++i) { for(int j=i+1;j<n;++j) { str[arr[i]^arr[j]]++; } } for(auto &it:str) { if(it>1) { ans+=(it*(it-1)); } } cout<<4*ans<<" "; }
@HarshSharma-hi9vc
@HarshSharma-hi9vc 5 күн бұрын
question 3 observation is just genius
@lostsky7656
@lostsky7656 5 күн бұрын
Amazing explanation