[Codeforces] Round 926 (Div. 2) D. Sasha and a Walk in the CityRead more
[Codeforces] Round 924 (Div. 2) D. Lonely Mountain DungeonsRead more
[LeetCode] Number Complement

476. Number Complement

The complement of an integer is the integer you get when you flip all the 0‘s to 1‘s and all the 1‘s to 0‘s in its binary representation.

  • For example, The integer 5 is "101" in binary and its complement is "010" which is the integer 2.

Given an integer num, return its complement.

Read more
[Codeforces] Round 923 (Div. 3) F. MicrocycleRead more
[Codeforces] Round 928 (Div. 4) G. Vlad and Trouble at MITRead more
[Codeforces] Round 921 (Div. 2) D. Good TripRead more
[Codeforces] Educational Round 161 (Rated for Div. 2) D. Berserk MonstersRead more
[LeetCode] Count Substrings That Satisfy K-Constraint II

3261. Count Substrings That Satisfy K-Constraint II

You are given a binary string s and an integer k.

You are also given a 2D integer array queries, where queries[i] = [li, ri].

A binary string satisfies the k-constraint if either of the following conditions holds:

  • The number of 0‘s in the string is at most k.
  • The number of 1‘s in the string is at most k.

Return an integer array answer, where answer[i] is the number of substrings of s[li..ri] that satisfy the k-constraint.

Read more
[LeetCode] Find the Largest Palindrome Divisible by K

3260. Find the Largest Palindrome Divisible by K

You are given two positive integers n and k.

An integer x is called k-palindromic if:

  • x is a palindrome.

  • x is divisible by k.

Return the largest integer having n digits (as a string) that is k-palindromic.

Note that the integer must not have leading zeros.

Read more
[LeetCode] Maximum Energy Boost From Two Drinks

3259. Maximum Energy Boost From Two Drinks

You are given two integer arrays energyDrinkA and energyDrinkB of the same length n by a futuristic sports scientist. These arrays represent the energy boosts per hour provided by two different energy drinks, A and B, respectively.

You want to maximize your total energy boost by drinking one energy drink per hour. However, if you want to switch from consuming one energy drink to the other, you need to wait for one hour to cleanse your system (meaning you won’t get any energy boost in that hour).

Return the maximum total energy boost you can gain in the next n hours.

Note that you can start consuming either of the two energy drinks.

Read more