注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
不少技术公司在用codesiginal做coding轮评分,不管是OA还是onsite楼主经历过的
Uber, Square, Gusto, Instacart, Notion, Asana, Robinhood, Chime, Quora, Verkada, Tinder, Niantic, Uniswap, Circle
这里把所有遇到过的20道实战进行分享,每道尽力打上公司标签
You are given an array of strings arr. Your task is to construct a string from the words in arr, starting with the 0th character from each word (in the order they appear in arr), followed by the 1st character, then the 2nd character, etc. If one of the words doesn't have an ith character, skip that word.
Return the resulting string.
Example
* For arr = ["Daisy", "Rose", "Hyacinth", "Poppy"], the output should be solution(arr) = "DRHPaoyoisapsecpyiynth".
实力代码
def solution(arr):
q, res = [] ,deque([])
for i in range(len(arr)):
if arr[i]:
q.append((i,0))
while q:
i, pos = q.popleft()
res.append(arr[i][pos])
if pos+1 < len(arr[i]):
pos += 1
q.append((i, pos))
return "".join(res)
|