注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
70分钟4道题,整体不算很难。 Q3是个矩阵,代码有点复杂,Q4需要用二分查找不然有一半的case过不了。
求大米🙏
Q1:You are given an array of integers numbers and an integer pivot.
Your task is to return a new array in which the ith element equals:
• 0 if numbers[i] is zero.
• 1 if numbers[i] and pivot have the same sign (both positive or both negative).
• -1 if numbers[i] and pivot have different signs.
Note: It is guaranteed that pivot isn't equal to zero. Also note that you are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(numbers.length2) will fit within the execution time limit.
Q2:
Imagine two cities, A and B, connected by direct flights. Flights from A to B take 100 minutes and depart at times specified in a sorted integer array aeck -2 through 2 on the number line for obstacles. Produces "1" if it is possible, i.e., if there are no obstacles at the specified coordinates, and produces "0" otherwise. Please note that this operation does not actually build the block, it only checks whether a block can be built. Given an array of operations containing both types of operations above, your task is to return a binary string representing the outputs for all [2, x, size] operations. |