1352. Product of the Last K Numbers
Design an algorithm that accepts a stream of integers and retrieves the product of the last k integers of the stream. Implement […]
Design an algorithm that accepts a stream of integers and retrieves the product of the last k integers of the stream. Implement […]
You are given a 0-indexed integer array nums, and an integer k. In one operation, you will: Take the two smallest integers x and y in nums. Remove x and y from nums. Add min(x,
You are given a 0-indexed array nums consisting of positive integers. You can choose two indices i and j, such that i != j, and the sum of digits of
Given two strings s and part, perform the following operation on s until all occurrences of the substring part are removed: Find the leftmost occurrence of the substring part and remove it from s. Return s after removing
You are given a string s. Your task is to remove all digits by doing this operation repeatedly: Delete the first digit and the closest non-digit character to
You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not
Given an array of positive integers nums, return the maximum possible sum of an ascending subarray in nums. A subarray is defined as a contiguous
An array is considered special if every pair of its adjacent elements contains two numbers with different parity. You are given an
You are given a positive integer n representing the number of nodes in an undirected graph. The nodes are labeled from 1 to n. You are also
In this problem, a tree is an undirected graph that is connected and has no cycles. You are given a graph that
You are given a 0-indexed 2D matrix grid of size m x n, where (r, c) represents: A land cell if grid[r][c] = 0, or A water cell containing grid[r][c] fish, if grid[r][c] > 0.
There are a total of numCourses courses you have to take, labeled from 0 to numCourses – 1. You are given an array prerequisites where prerequisites[i] = [ai,