Reveal Cards In Increasing Order | 2 Approaches | Leetcode 950 | codestorywithMIK
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 2nd Video of our Playlist "Queue: Popular Interview Problems".
In this video we will try to solve an easy but a very good Queue and Simulation based problem : Reveal Cards In Increasing Order
| 2 Approaches | Leetcode 950
I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.
Problem Name : Reveal Cards In Increasing Order
| 2 Approaches | Leetcode 950 | codestorywithMIK
Company Tags : Will update soon
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Queue/Reveal%20Cards%20In%20Increasing%20Order.cpp
Leetcode Link :
https://leetcode.com/problems/reveal-cards-in-increasing-order/description/
My DP Concepts Playlist : https://youtu.be/7eLMOE1jnls
My Graph Concepts Playlist : https://youtu.be/5JGiZnr6B5w
My Recursion Concepts Playlist : https://www.youtube.com/watch?v=pfb1Zduesi8&list=PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM
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 : https://www.youtube.com/@codestorywithMIK
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
✨ Timelines✨
00:00 - Introduction
5:10 - Intuition Building
15:47 - Approach-1 Dry Run
23:27 - Coding Approach-1
28:01 - Approach-2 Intuition & Explanation & Dry Run
35:14 - Coding Approach-2
Summary :
Approach-1 (Simulation):
- This approach involves simulating the process of revealing cards according to the given rules without using any extra data structures besides the result array.
- It sorts the input deck vector in ascending order to simulate revealing the cards in increasing order.
- It iterates through the result array and fills it with cards from the sorted deck, skipping every other empty position.
- Time Complexity (T.C): O(nlogn) due to sorting the deck.
- Space Complexity (S.C): O(1) as it uses only a constant amount of extra space besides the input and output arrays.
Approach-2 (Simulation using Queue):
- This approach also simulates the process but utilizes a queue to keep track of the indices where cards will be revealed.
- It sorts the deck vector in ascending order and then iterates through it, revealing the cards according to the queue's order.
- It maintains a queue with indices representing the positions in the result array.
- Time Complexity (T.C): O(nlogn) due to sorting the deck.
- Space Complexity (S.C): O(n) because of using a queue of size n to store indices. Additionally, the result array also occupies O(n) space.
#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 #newyear2024