Alice and Bob Playing Flower Game | Hindi Explanation | Leetcode 3021 | Leetcode Daily Challenge
Автор: Code with Deepak
Загружено: 2025-08-28
Просмотров: 250
In this video, we solve Leetcode 3021. Alice and Bob Playing Flower Game using Java.
Solution: https://github.com/deepak-sharma-iOS/...
Question Link - https://leetcode.com/problems/alice-a...
Linkedin - / deepak-sharmaa-dev
Subscribe - / @debugwithdeepak
Github - https://github.com/deepak-sharma-iOS/...
Video Summary:
This solution solves the *flower game* problem. Initially, it used a recursive approach with `aliceTurn` and `bobTurn` to check winning states, but that led to *exponential time complexity* due to repeated recomputation of the same states. To fix this, the code introduced *DP memoization* (`aliceDP` and `bobDP`) to cache results and avoid redundant work. However, instead of running full recursion, the optimized `helper()` uses a *mathematical formula* based on counting odd/even petals, giving an *O(1) solution**. The main issue in the pure recursive approach was **TLE and possible stack overflow* for large `n` and `m`.
🕒 Timeline Overview
0:00 Question Understanding
1:43 Example
7:37 Recursive Logic
13:23 Recursive Code
21:39 Optimization Logic
27:32 Optimized Code
#CodeWithDeepak #LeetCodeDailyChallenge #LeetCodeSolutions #DSAforInterviews #CodingWithExplanation #TechInterviewPrep #CrackTheCodingInterview #DailyCodingChallenge #JavaCoding #LearnToCode #CodingShorts #leetcodedailychallenge
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: