2940. Find Building Where Alice and Bob Can Meet
You are given a 0-indexed array
heightsof positive integers, whereheights[i]represents the height of theithbuilding.If a person is in building
i, they can move to any other buildingjif and only ifi < jandheights[i] < heights[j].You are also given another array
querieswherequeries[i] = [ai, bi]. On theithquery, Alice is in buildingaiwhile Bob is in buildingbi.Return an array
answhereans[i]is the index of the leftmost building where Alice and Bob can meet on theithquery. If Alice and Bob cannot move to a common building on queryi, setans[i]to-1.
Given three integers
a,b, andn, return the maximum value of(a XOR x) * (b XOR x)where0 <= x < 2n.Since the answer may be too large, return it modulo
109 + 7.Note that
XORis the bitwise XOR operation.
2938. Separate Black and White Balls
There are
nballs on a table, each ball has a color black or white.You are given a 0-indexed binary string
sof lengthn, where1and0represent 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.
2937. Make Three Strings Equal
You are given three strings
s1,s2, ands3. 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
2and 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.