注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
4题,难度总体来说中等,最后一题有几个test case没过。分享求米,谢谢!1. 很简单,略
2,3,4地里都有出现过, 这里再复制黏贴一下
2. given a list of unix commands (cp, ls, mv, $1, $4), return a list of how many times each are called (note $4 ⇒ $1 ⇒ cp)
3. Imagine a board of size numRows × numColumns with some lasers placed on it. These lasers are placed at coordinates specified in the two-dimensional array laserCoordinates, where laserCoordinates[i] is a two-element array containing coordinates for the center of the ith laser. Lasers with a center in a cell (row, column) destroy everything in the same row (i.e. rows with index row) and the same column (i.e. columns with index column).
Now imagine there is a robot at coordinates (curRow, curColumn). The robot can only move in a straight line, either left, right, up, or down within this board. Your task is to count the maximum number of cells that the robot can safely move through (in any direction) before being destroyed by lasers.
Note: You can assume that the initial cell is protected, and lasers cannot destroy the robot there even if they cover this cell in their destruction area.
Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(numRows · numColumns · laserCoordinates.length) will fit wi您好! 本帖隐藏的内容需要积分高于 188 才可浏览 您当前积分为 0。 使用VIP即刻解锁阅读权限或查看其他获取积分的方式 游客,您好! 本帖隐藏的内容需要积分高于 188 才可浏览 您当前积分为 0。 VIP即刻解锁阅读权限 或 查看其他获取积分的方式 find the number of lamps lamps[i] which include this point within its covered segment - when points[j] lies inside the segment [lamps[i][0], lamps[i][1]].
As a result, return an array of integers, where ith integer corresponds to the answer for the ith control point.
Example
For lamps = [[1, 7], [5, 11], [7, 9]] and points = [7, 1, 5, 10, 9, 15], the output should be solution(lamps, points) = [3, 1, 2, 1, 2, 0]. |