Leetcode 0348. Design Tic-Tac-Toe

Posted on Thu 05 December 2024 in Leetcode Premium • Tagged with simulation

Question Link : https://leetcode.com/problems/design-tic-tac-toe/

Difficulty: Medium

Premium: True

Question

Assume the following rules are for the tic-tac-toe game on an n x n board between two players:

A move is guaranteed to be valid and is placed on an empty block. Once a winning condition is reached …


Continue reading

Leetcode 0755. Pour Water

Posted on Tue 26 November 2024 in Leetcode Premium • Tagged with simulation, array

Question Link : https://leetcode.com/problems/pour-water/

Difficulty: Medium

Premium: True

Question

You are given an elevation map represents as an integer array heights where heights[i] representing the height of the terrain at index i. The width at each index is 1. You are also given two integers volume …


Continue reading

Leetcode 1431. Kids With the Greatest Number of Candies

Posted on Sun 16 April 2023 in Leetcode • Tagged with simulation

Question Link : https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/

Difficulty: Easy

Premium: False

Question

There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, and an integer extraCandies, denoting the number of extra candies that you …


Continue reading

Leetcode 0495. Teemo Attacking

Posted on Sun 13 November 2022 in Leetcode • Tagged with greedy, interval-merge, simulation

Question Link : https://leetcode.com/problems/teemo-attacking/

Difficulty: Easy

Question

Our hero Teemo is attacking an enemy Ashe with poison attacks! When Teemo attacks Ashe, Ashe gets poisoned for a exactly duration seconds. More formally, an attack at second t will mean Ashe is poisoned during the inclusive time interval …


Continue reading

Leetcode 2437. Number of Valid Clock Times

Posted on Tue 08 November 2022 in Leetcode • Tagged with simulation

Question Link : https://leetcode.com/problems/number-of-valid-clock-times/

Difficulty: Easy

Question

You are given a string of length 5 called time, representing the current time on a digital clock in the format "hh:mm". The earliest possible time is "00:00" and the latest possible time is "23:59". In the …


Continue reading

Leetcode 2293. Min Max Game

Posted on Wed 08 June 2022 in Leetcode • Tagged with recursion, simulation

Question Link : https://leetcode.com/problems/min-max-game/

Difficulty: Easy

Question

You are given a 0-indexed integer array nums whose length is a power of 2. Apply the following algorithm on nums:

Let n be the length of nums. If n == 1, end the process. Otherwise, create a new 0-indexed integer …


Continue reading

Leetcode 0289. Game of Life

Posted on Mon 11 April 2022 in Leetcode • Tagged with simulation, state-changes

Question Link : https://leetcode.com/problems/game-of-life/

Difficulty: Medium

Question

According to Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970." The board is made up of an m x n grid of cells …


Continue reading

Leetcode 0682. Baseball Game

Posted on Sat 09 April 2022 in Leetcode • Tagged with simulation

Question Link : https://leetcode.com/problems/baseball-game/

Difficulty: Easy

Question

You are keeping score for a baseball game with strange rules. The game consists of several rounds, where the scores of past rounds may affect future rounds' scores. At the beginning of the game, you start with an empty record …


Continue reading

Leetcode 0946. Validate Stack Sequences

Posted on Tue 15 March 2022 in Leetcode • Tagged with stack, simulation, greedy

Question Link : https://leetcode.com/problems/validate-stack-sequences/

Difficulty: Medium

Question

Given two integer arrays pushed and popped each with distinct values, return true if this could have been the result of a sequence of push and pop operations on an initially empty stack, or false otherwise.   Example 1:

Input: pushed …


Continue reading

Leetcode 0799. Champagne Tower

Posted on Thu 03 March 2022 in Leetcode • Tagged with simulation

Question Link : https://leetcode.com/problems/champagne-tower/

Difficulty: Medium

Question

We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100th row.  Each glass holds one cup of champagne. Then, some champagne is poured into the …


Continue reading