Grid Game | Detailed Explanation | Complete Ry Run | Leetcode 2017 | codestorywithMIK
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
Hi Everyone, this is the 137th video of our Playlist "Arrays 1D/2D : Popular Interview Problems".
Now we will be solving a very good problem based on Game Strategy in a 2D Array Game - Grid Game | Detailed Explanation | Complete Ry Run | Leetcode 2017 | codestorywithMIK
Problem Name : Grid Game | Detailed Explanation | Complete Ry Run | Leetcode 2017 | codestorywithMIK
Company Tags : will update later
My solutions on Github(C++ & JAVA) - https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Arrays/Cumulative_Sum(Prefix Array)/Grid Game.cpp
Leetcode Link : https://leetcode.com/problems/grid-game
My DP Concepts Playlist : • Roadmap for DP | How to Start DP ? | ...
My Graph Concepts Playlist : • Graph Concepts & Qns - 1 : Graph will...
My Segment Tree Concepts Playlist : • Segment Tree | Introduction | Basics ...
My Recursion Concepts Playlist : • Introduction | Recursion Concepts And...
Trie Playlist - • Word Search II (Google, Amazon, Meta,...
Difference Array Technique: Concepts & Qns : • Introduction | What | How | Differenc...
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK
Subscribe to my channel : / @codestorywithmik
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
Video Summary :
The problem involves two robots, Robot1 and Robot2, navigating through a 2D grid. Robot1 moves first and selects a column in the grid, while Robot2 moves afterward and tries to minimize the remaining sum in the second row of the grid. The goal is to minimize the sum that Robot2 has to deal with after Robot1 has made its move.
Thought Process:
Initial Setup: The sum of all elements in the first row (firstRowRemainSum) is calculated at the start. This helps track the remaining sum for Robot1's strategy.
Iterative Strategy: For each column, Robot1 "takes" that column by subtracting the value from firstRowRemainSum. This simulates Robot1's choice.
Robot2's Best Response: After Robot1's choice, Robot2 attempts to minimize the remaining sum in the second row by selecting the best possible outcome (max between remaining sums of the first and second rows).
Tracking the Minimum: The goal is to track the minimum possible sum for Robot2 by updating minimizedRobot2Sum at each step.
Approach:
Accumulation: The sum of the first row is accumulated at the start, and then progressively updated as Robot1 moves.
Max/Min Operations: For each column, the maximum of the remaining sum of the first row and the accumulated sum of the second row is calculated, and the minimum of these values is tracked.
Efficiency: The algorithm processes each column once, resulting in a time complexity of O(col), where col is the number of columns in the grid.
Intuition:
✨ Timelines✨
00:00 - Introduction
0:15 - Motivation
0:41 - Problem Explanation
5:01 - Thought Process and Intuition
21:17 - Complete Dry Run
29:39 - Coding it up
#MIK #mik #Mik
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #coding #programming #100daysofcode #developers #techjobs #datastructures #algorithms #webdevelopment #softwareengineering #computerscience #pythoncoding #codinglife #coderlife #javascript #datascience #leetcode #leetcodesolutions #leetcodedailychallenge #codinginterview #interviewprep #technicalinterview #interviewtips #interviewquestions #codingchallenges #interviewready #dsa #hindi #india #hindicoding #hindiprogramming #hindiexplanation #hindidevelopers #hinditech #hindilearning #helpajobseeker #jobseekers #jobsearchtips #careergoals #careerdevelopment #jobhunt #jobinterview #github #designthinking #learningtogether #growthmindset #digitalcontent #techcontent #socialmediagrowth #contentcreation #instagramreels #videomarketing #codestorywithmik #codestorywithmick #codestorywithmikc #codestorywitmik #codestorywthmik #codstorywithmik #codestorywihmik #codestorywithmiik #codeistorywithmik #codestorywithmk #codestorywitmick #codestorymik #codestorwithmik