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 0163. Missing Ranges

Posted on Fri 22 November 2024 in Leetcode Premium • Tagged with array

Question Link : https://leetcode.com/problems/missing-ranges/

Difficulty: Easy

Premium: True

Question

You are given an inclusive range [lower, upper] and a sorted unique integer array nums, where all elements are within the inclusive range. A number x is considered missing if x is in the range [lower, upper] and …


Continue reading

Leetcode 2348. Number of Zero-Filled Subarrays

Posted on Mon 20 March 2023 in Leetcode • Tagged with array, math

Question Link : https://leetcode.com/problems/number-of-zero-filled-subarrays/

Difficulty: Medium

Premium: False

Question

Given an integer array nums, return the number of subarrays filled with 0. A subarray is a contiguous non-empty sequence of elements within an array.   Example 1:

Input: nums = [1,3,0,0,2,0,0,4] Output …


Continue reading

Leetcode 0605. Can Place Flowers

Posted on Sun 19 March 2023 in Leetcode • Tagged with array

Question Link : https://leetcode.com/problems/can-place-flowers/

Difficulty: Easy

Premium: False

Question

You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots. Given an integer array flowerbed containing 0's and 1's, where 0 means empty …


Continue reading

Leetcode 1470. Shuffle the Array

Posted on Sun 05 February 2023 in Leetcode • Tagged with array

Question Link : https://leetcode.com/problems/shuffle-the-array/

Difficulty: Easy

Premium: False

Question

Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn]. Return the array in the form [x1,y1,x2,y2,...,xn,yn].   Example 1:

Input: nums = [2,5,1,3,4 …


Continue reading

Leetcode 0380. Insert Delete GetRandom O(1)

Posted on Mon 28 November 2022 in Leetcode • Tagged with hash-map, array

Question Link : https://leetcode.com/problems/insert-delete-getrandom-o1/

Difficulty: Medium

Premium: False

Question

Implement the RandomizedSet class:

RandomizedSet() Initializes the RandomizedSet object. bool insert(int val) Inserts an item val into the set if not present. Returns true if the item was not present, false otherwise. bool remove(int val) Removes …


Continue reading

Leetcode 2451. Odd String Difference

Posted on Sat 05 November 2022 in Leetcode • Tagged with array, counting

Question Link : https://leetcode.com/problems/odd-string-difference/

Difficulty: Easy

Question

You are given an array of equal-length strings words. Assume that the length of each string is n. Each string words[i] can be converted into a difference integer array difference[i] of length n - 1 where difference[i][j …


Continue reading

Leetcode 0334. Increasing Triplet Subsequence

Posted on Mon 10 October 2022 in Leetcode • Tagged with array

Question Link : https://leetcode.com/problems/increasing-triplet-subsequence/

Difficulty: Medium

Question

Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that i < j < k and nums[i] < nums[j] < nums[k]. If no such indices exists, return false.   Example 1:

Input: nums …


Continue reading

Leetcode 2432. The Employee That Worked on the Longest Task

Posted on Sun 09 October 2022 in Leetcode • Tagged with array

Question Link : https://leetcode.com/problems/the-employee-that-worked-on-the-longest-task/

Difficulty: Easy

Question

There are n employees, each with a unique id from 0 to n - 1. You are given a 2D integer array logs where logs[i] = [idi, leaveTimei] where:

idi is the id of the employee that worked on the ith …


Continue reading

Leetcode 1578. Minimum Time to Make Rope Colorful

Posted on Mon 03 October 2022 in Leetcode • Tagged with pointers, array

Question Link : https://leetcode.com/problems/minimum-time-to-make-rope-colorful/

Difficulty: Medium

Question

Alice has n balloons arranged on a rope. You are given a 0-indexed string colors where colors[i] is the color of the ith balloon. Alice wants the rope to be colorful. She does not want two consecutive balloons to …


Continue reading