[AtCoder] E - OversleepingRead more
[Codeforces] Round #219 (Div. 2) B. Making Sequences is FunRead more
[Codeforces] Round #219 (Div. 1) A. Counting Kangaroos is FunRead more
[Codeforces] Round #218 (Div. 2) C. HamburgersRead more
[Codeforces] Round #216 (Div. 2) C. Valera and ElectionsRead more
[Codeforces] Round #213 (Div. 1) A. MatrixRead more
[LeetCode] Number of Great Partitions

2518. Number of Great Partitions

You are given an array nums consisting of positive integers and an integer k.

Partition the array into two ordered groups such that each element is in exactly one group. A partition is called great if the sum of elements of each group is greater than or equal to k.

Return the number of distinct great partitions. Since the answer may be too large, return it modulo 109 + 7.

Two partitions are considered distinct if some element nums[i] is in different groups in the two partitions.

Read more
[LeetCode] Maximum Tastiness of Candy Basket

2517. Maximum Tastiness of Candy Basket

You are given an array of positive integers price where price[i] denotes the price of the ith candy and a positive integer k.

The store sells baskets of k distinct candies. The tastiness of a candy basket is the smallest absolute difference of the prices of any two candies in the basket.

Return the maximum tastiness of a candy basket.

Read more
[LeetCode] Take K of Each Character From Left and Right

2516. Take K of Each Character From Left and Right

You are given a string s consisting of the characters ‘a’, ‘b’, and ‘c’ and a non-negative integer k. Each minute, you may take either the leftmost character of s, or the rightmost character of s.

Return the minimum number of minutes needed for you to take at least k of each character, or return -1 if it is not possible to take k of each character.

Read more
[LeetCode] Shortest Distance to Target String in a Circular Array

2515. Shortest Distance to Target String in a Circular Array

You are given a 0-indexed circular string array words and a string target. A circular array means that the array’s end connects to the array’s beginning.

  • Formally, the next element of words[i] is words[(i + 1) % n] and the previous element of words[i] is words[(i - 1 + n) % n], where n is the length of words.

Starting from startIndex, you can move to either the next word or the previous word with 1 step at a time.

Return the shortest distance needed to reach the string target. If the string target does not exist in words, return -1.

Read more