[LeetCode] Find Building Where Alice and Bob Can Meet

2940. Find Building Where Alice and Bob Can Meet

You are given a 0-indexed array heights of positive integers, where heights[i] represents the height of the ith building.

If a person is in building i, they can move to any other building j if and only if i < j and heights[i] < heights[j].

You are also given another array queries where queries[i] = [ai, bi]. On the ith query, Alice is in building ai while Bob is in building bi.

Return an array ans where ans[i] is the index of the leftmost building where Alice and Bob can meet on the ith query. If Alice and Bob cannot move to a common building on query i, set ans[i] to -1.

Read more
[LeetCode] Maximum Xor Product

2939. Maximum Xor Product

Given three integers a, b, and n, return the maximum value of (a XOR x) * (b XOR x) where 0 <= x < 2n.

Since the answer may be too large, return it modulo 109 + 7.

Note that XOR is the bitwise XOR operation.

Read more
[LeetCode] Separate Black and White Balls

2938. Separate Black and White Balls

There are n balls on a table, each ball has a color black or white.

You are given a 0-indexed binary string s of length n, where 1 and 0 represent black and white balls, respectively.

In each step, you can choose two adjacent balls and swap them.

Return the minimum number of steps to group all the black balls to the right and all the white balls to the left.

Read more
[LeetCode] Make Three Strings Equal

2937. Make Three Strings Equal

You are given three strings s1, s2, and s3. You have to perform the following operation on these three strings as many times as you want.

In one operation you can choose one of these three strings such that its length is at least 2 and delete the rightmost character of it.

Return the minimum number of operations you need to perform to make the three strings equal if there is a way to make them equal, otherwise, return -1.

Read more
[Codeforces] April Fools Day Contest 2016 E. Out of ControlsRead more
[Codeforces] Round 346 (Div. 2) F. Polycarp and HayRead more
[Codeforces] CROC 2016 - Final Round [Private, For Onsite Finalists Only] D. International OlympiadRead more
[Codeforces] Round 349 (Div. 1) B. World TourRead more
[Codeforces] Round 352 (Div. 1) B. Robin HoodRead more
[AtCoder] E - Somen NagashiRead more