注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
本帖最后由 闭眼默数100 于 2021-5-15 23:51 编辑
早上刚做的, 两道题, 都是地理的。
1. transaction logs:
给一个 array of string, 每个string的格式是“S R A”。S, R, A 都是integer, 以空格隔开。 S 是发送者的id, R是接收者的id, A是大米的amount。 然后给出一个threshold.
返回list of string, 每一个string 的是 参与transaction 次数不少于 threshold 的人的 id。 这些id 要以对应integer的升序sort。 题目中说"S S A" 这种, S算参与了一次transaction。
sol:用一个hashmap count 一下3]. pipeAtRight, pipeAtLeft, preSum 都是1-index。
对于 start = 1, end = 5。 pipeAtRight[start] = 2, pipeAtLeft[end] = 4, preSum[4] - presum[2] = 2 - 1 = 1.
希望能给下一轮。
|