Back to Browse

2017. Grid Game | leetcode daily challenge | shashcode | java | dsa | shashwat | hindi

2.7K views
Jan 21, 2025
14:11

Problem Link: https://leetcode.com/problems/grid-game/description/?envType=daily-question&envId=2025-01-21 Problem Statement: You are given a 0-indexed 2D array grid of size 2 x n, where grid[r][c] represents the number of points at position (r, c) on the matrix. Two robots are playing a game on this matrix. Both robots initially start at (0, 0) and want to reach (1, n-1). Each robot may only move to the right ((r, c) to (r, c + 1)) or down ((r, c) to (r + 1, c)). At the start of the game, the first robot moves from (0, 0) to (1, n-1), collecting all the points from the cells on its path. For all cells (r, c) traversed on the path, grid[r][c] is set to 0. Then, the second robot moves from (0, 0) to (1, n-1), collecting the points on its path. Note that their paths may intersect with one another. The first robot wants to minimize the number of points collected by the second robot. In contrast, the second robot wants to maximize the number of points it collects. If both robots play optimally, return the number of points collected by the second robot. Solution Link: https://github.com/Tiwarishashwat/InterviewCodes/blob/main/gridGame.java Custom Comparator: https://youtu.be/quegYlReztM?si=G265RK8IFpP92_4b Lambda Expression: https://youtu.be/3DkmAUdrzKw?si=q9pqrvNPKAXt1g0d Dynamic Programming: https://youtu.be/P3MFBCZCGXs?si=A832THtbhyqPNAf2 Graph Playlist: https://www.youtube.com/playlist?list=PLQ7ZAf76c0ZOGuMjg3qwNgILb_dKWTxyQ Java Plus DSA Placement Course Playlist: https://youtube.com/playlist?list=PLQ7ZAf76c0ZPVdhV1bAjFv0bQc1xHURzE Java Plus DSA Sheet: https://docs.google.com/spreadsheets/d/119u25NO-4ZJ9zwfUKs5eGNo0exCVq3gZEFWvkCDiMqI/edit?usp=sharing Notes: https://github.com/Tiwarishashwat/Java-Plus-DSA-Placement-Course Telegram Link: https://shashwattiwari.page.link/telegramShashwat Ultimate Recursion Series Playlist: https://youtube.com/playlist?list=PLQ7ZAf76c0ZMzC9OHPbo-dUgx6oU3T0jK Instagram Handle: (@shashwat_tiwari_st) https://shashwattiwari.page.link/shashwatInsta Samsung Interview Experience: https://youtu.be/GrvlpBzphSU Company Tags: Facebook | Amazon | Microsoft | Netflix | Google | LinkedIn | Pega Systems | VMware | Adobe | Samsung Timestamp: 0:00 - Introduction

Download

0 formats

No download links available.

2017. Grid Game | leetcode daily challenge | shashcode | java | dsa | shashwat | hindi | NatokHD