GFG Weekly Coding Contest - 161 Post Analysis | GeeksforGeeks Practice

  Рет қаралды 1,404

GeeksforGeeks Practice

GeeksforGeeks Practice

12 күн бұрын

Join us for a post-contest analysis with Jay Dalsaniya where we will be discussing the problems from the GFG Weekly Coding Contest - 161. In this session, Jay will be sharing his approach to solving problems and providing valuable insights on how to approach similar problems in the future.
Whether you participated in the contest or not, this session is a great opportunity to learn new problem-solving techniques and deepen your understanding of data structures and algorithms. You'll have the chance to ask questions and interact with other participants, making this a fun and engaging learning experience.
🏆 Register for the Upcoming GFG Weekly Coding Contest 161: practice.geeksforgeeks.org/co...
-----------------------------------------------------------------------------------------
📆 Solve PROBLEM OF THE DAY Daily: practice.geeksforgeeks.org/pr...
📖 Master Competitive Programming: practice.geeksforgeeks.org/co...
-----------------------------------------------------------------------------------------
Follow us and stay updated on everything happening in the world of geeks:
📱 Twitter- / geeksforgeeks
📝 LinkedIn- / geeksforgeeks
🌐 Facebook- / geeksforgeeks.org
📷 Instagram- geeks_for_g...
#GFGPractice #GeeksforGeeks #WeeklyCodingContest #CodingQuestions
#WeeklyCodingContest161 #JayDalsaniya

Пікірлер: 38
@sahilshrivastava6455
@sahilshrivastava6455 10 күн бұрын
much better than last post analysis video but why question 4 is missing
@ITACHIUCHIHA-dr8sz
@ITACHIUCHIHA-dr8sz 11 күн бұрын
what the actual hell, skipped the last question conviniently and still call it "post analysis"
@kashishchawla2754
@kashishchawla2754 11 күн бұрын
++
@nishantsah6981
@nishantsah6981 11 күн бұрын
they are skipping the last problem since past 3 contests don't know why
@user-dn7gj3lk6t
@user-dn7gj3lk6t 10 күн бұрын
Bro it is segment tree+prefix sum problem
@es_amit
@es_amit 11 күн бұрын
We want live stream back, as we can't be able grasp concept properly 😤😤
@viveksahane1314
@viveksahane1314 11 күн бұрын
codes kha hein ??
@aayushsharma8170
@aayushsharma8170 4 күн бұрын
Get Segments class Solution { public: int getSegments(vector arr, int n, int x) { int segments = 1; // Start with at least one segment int current_or = 0; for (int i = 0; i < n; ++i) { current_or |= arr[i]; if (current_or > x) { // Start a new segment segments++; current_or = arr[i]; // Start the new segment with the current element } } return segments; } };
@deepak3554
@deepak3554 10 күн бұрын
I was looking for last questions approach...but it's not here..sad
@aizad786iqbal
@aizad786iqbal 6 күн бұрын
great explanation please add 4th question... also take much bigger test case.... like N = 15 or 20....(next time)
@rohithsinghthakur968
@rohithsinghthakur968 10 күн бұрын
Question no 4 is missing in the video, please upload the Question no 4 solution video.
@aayushsharma8170
@aayushsharma8170 4 күн бұрын
Odd Minus Prime class Solution { public: long long maximumSum(int n, int k) { // Step 1: Identify prime numbers up to n using the Sieve of Eratosthenes vector isPrime(n + 1, true); isPrime[0] = isPrime[1] = false; for (int i = 2; i * i
@aizad786iqbal
@aizad786iqbal 6 күн бұрын
where is part2 @GeeksforGeeksPractice ??
@aizad786iqbal
@aizad786iqbal 6 күн бұрын
2nd question, i and j being same would never be co prime right?
@kumkumslab5811
@kumkumslab5811 10 күн бұрын
why second questions was giving TLE in 0(nlogn) it should not right, while a[i] can upto 1e9 so it should not submitted in map soln
@prantobala8505
@prantobala8505 10 күн бұрын
use unordered map in C++.
@Benstokes4444
@Benstokes4444 9 күн бұрын
you re using sorting extra space in map
@kumkumslab5811
@kumkumslab5811 10 күн бұрын
MY approach of max size array int i=0,j=n-1; unordered_mapmp; for(auto i:A){ mp[i]++; } priority_queue pq; for(auto &i:mp){ pq.push(i.second); } // Reduce pairs while (pq.size() > 1) { int freq1 = pq.top(); pq.pop(); int freq2 = pq.top(); pq.pop(); // If the frequencies are different, push back the difference if (freq1 > freq2) { pq.push(freq1 - freq2); } } // If the priority queue is empty, it means all elements were paired off if (pq.empty()) { return 0; } return pq.top();
@AnikBhowmickaeb
@AnikBhowmickaeb 9 күн бұрын
Your technique is very intuitive than what he discussed in the solution. The question setters will always have the idea and approach in their mind to solve the problem, the observations he explained in the solution is very hard to come up with during the contest. For this question I used vector after the unordered map and sorted it instead of using priority queue and then used two pointer approach to iterate on the vector. O(nlogn) approach is far better for this problem.
@taradean.
@taradean. 9 күн бұрын
@@AnikBhowmickaeb exactly, this was my first weekly contest, i could barely solve 1 question half way but had to use cgpt even after test to come up with the right soln, but still it showed me TLE. then i tried this max array diff question and all my approaches are getting tle, i was and i still am so scared if this is the normal level of questions during oa of companies, idk how i'd survive. i cant even imagine coming up with the intuition or approach these problem setters have planned or what he explained in the video, ur comment relaxed me a bit thank you!
@inspirationalshorts2689
@inspirationalshorts2689 11 күн бұрын
Why the Map is not working in And is Equal to Or Question because basically we calculating frequency and find counts, so Why using Map given Wrong Answer?
@praneeth123-w6w
@praneeth123-w6w 11 күн бұрын
I have same doubt
@sakshampathak1610
@sakshampathak1610 10 күн бұрын
​​​@@praneeth123-w6w Test Case - 1 1 1 2 1 1 I think this case will fail with Map as u will count the freq of 1 as 5 and calculate sub array accordingly .
@shriyanshvishwakarma3432
@shriyanshvishwakarma3432 10 күн бұрын
@praneeth123-w6w Okay Assume this test cases 1. arr = [1,2,2,2,4] HashMap value will be map ={1:1, 2:3, 4:1} Now even the total TC should be 9 i.e => [0,0],[1,1],[1,2],[1,2,3],[1,3],[2,2],[2,3],[3,3],[4,4] . * They are the index numbers on 0 based indexing. But the sum based on HashMap is 1+ 3+ 1 => 5 which is wrong. I hope it helps 😉
@asmitamhetre
@asmitamhetre 10 күн бұрын
coz here in this we want subarray (continuous elements) if u use map it wont be continues ; long long int ans = n; for(int i = 0 ; i < n ; i++) { long long cnt = 0; int j = i+1; while(j < n && arr[j] == arr[i]){ cnt++; j++; } if(cnt > 0) { ans += ((cnt)*(cnt+1)/2); i = j-1; } } return ans; this might help
@praneeth123-w6w
@praneeth123-w6w 10 күн бұрын
@@shriyanshvishwakarma3432 how [1,3] is going to come and i use formula(n(n+1))/2 for each count ?
@aizad786iqbal
@aizad786iqbal 6 күн бұрын
public static long ANDequalOR(int n, int[] arr) { // code here HashMap hmap = new HashMap(); long ans = n; long same=1; for(int i=1;i
@prakhargarg4166
@prakhargarg4166 10 күн бұрын
where is hard one
@31ankitnain41
@31ankitnain41 3 күн бұрын
158 contest hi uda dia yr tumhaara bus ki nahi to rehna do bol bol ka thak gaya 158 isma bhi 4th missing
@aayushsharma8170
@aayushsharma8170 4 күн бұрын
Counting N-Digit Numbers with a 7 class Solution { public: const int MOD = 1000000007; // Function to perform modular exponentiation long long mod_exp(long long base, long long exp, long long mod) { long long result = 1; while (exp > 0) { if (exp % 2 == 1) { result = (result * base) % mod; } base = (base * base) % mod; exp = exp / 2; } return result; } int countWays(int n) { if (n == 1) { return 1; } long long total_numbers = (9 * mod_exp(10, n - 1, MOD)) % MOD; long long numbers_without_7 = (8 * mod_exp(9, n - 1, MOD)) % MOD; long long result = (total_numbers - numbers_without_7 + MOD) % MOD; return result; } };
@maddy-jn3ti
@maddy-jn3ti 10 күн бұрын
1st question can be done in O(n) time complexity, why did you not do that? instructors must be more qualified I guess
@AnikBhowmickaeb
@AnikBhowmickaeb 9 күн бұрын
yeah just a simple 2 pointer approach.
@jaydalsaniya6986
@jaydalsaniya6986 8 күн бұрын
Please see the code, the TC of the approach explained it O(n).
@ashutoshgiri2974
@ashutoshgiri2974 11 күн бұрын
❤️
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 202 М.
Jonathan Blow on why C++ is a bad language for games
13:45
Jonathan Blow Highlights
Рет қаралды 45 М.
Самое Романтичное Видео ❤️
00:16
Глеб Рандалайнен
Рет қаралды 6 МЛН
Мы никогда не были так напуганы!
00:15
Аришнев
Рет қаралды 6 МЛН
WHO LAUGHS LAST LAUGHS BEST 😎 #comedy
00:18
HaHaWhat
Рет қаралды 17 МЛН
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 318 М.
I Solved 1583 Leetcode Questions  Here's What I Learned
20:37
ThePrimeTime
Рет қаралды 564 М.
The ORDER BY Algorithm Is Harder Than You Think
13:46
Tony Saro
Рет қаралды 51 М.
GFG Weekly Coding Contest - 150 Post Analysis | GeeksforGeeks Practice
1:52:13
GeeksforGeeks Practice
Рет қаралды 1,8 М.
Rust Functions Are Weird (But Be Glad)
19:52
Logan Smith
Рет қаралды 129 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 769 М.
The Man Who Solved the World’s Hardest Math Problem
11:14
Newsthink
Рет қаралды 558 М.
GFG Weekly Coding Contest - 105 Post Analysis | GeeksforGeeks Practice
2:00:15
GeeksforGeeks Practice
Рет қаралды 2 М.
4 Sum | Brute - Better - Optimal with Codes
28:47
take U forward
Рет қаралды 133 М.
Самое Романтичное Видео ❤️
00:16
Глеб Рандалайнен
Рет қаралды 6 МЛН