All Posts
Leetcode 2555: Maximize Win From Two Segments
prizePositions
containing positions of prizes along a line and an integer k
. Your task is to select two segments of length k
such that you can maximize the number of prizes collected. The two segments may overlap, and you can collect all prizes within either of the segments.
You are given a sorted array Leetcode 2560: House Robber IV
A robber is tasked with stealing money from houses lined along a street. Each house has a certain amount of money, but the robber refuses to rob adjacent houses. The robber must steal from at least ‘k’ houses. Your goal is to determine the minimum amount of money the robber will steal from any house, out of all the possible ways of selecting at least ‘k’ houses, given the constraints.
Leetcode 2563: Count the Number of Fair Pairs
Given an integer array nums
of size n
and two integers lower
and upper
, find the number of fair pairs. A pair (i, j)
is considered fair if it satisfies the following conditions:
0 <= i < j < n
lower <= nums[i] + nums[j] <= upper
Return the number of such pairs.