字节跳动笔试题 2020.6.20

1.NodeList:a Nodelist A is input,hope Ur code could output a NodeList B constructed by the reversed neighbour Nodes in Nodelist A。
input:1>2>3>4>5>6
output: 2>1>4>3>6>5

2.Find The Only Number。An array[int] A is input, and the element in A is repeated twice (except the ONLY number),hope U find the ONLY number.
input:1 1 2 2 3 3 4
output:4
PS:Seems easy,actually it is easy in Hash.

3.Give Charge。coins[c1,c2,c3,c4…] and charge are input,find the minimum number of coins with a sum equaling to charge. If not exist, return -1.
input [1,2] 2
output 1

4.Glob Path Algorithm.

5.A 2d Array[int] A is input,Find a pair of (x1,y1), let the line of x=x1 and the line of y=y1 completely cover the points in A, with the minimum (1000x1+y1).If not exist, return (-1,-1).
input [[1,1][2,2]]
output (1,2)

6.Assuming U and Papa are very very borded in home,and there is a box and some balls, papa wanna play a game with U. The rule is, at begining there is some balls in the box, and the number of balls is N, if N is even, then papa will take away 0.5*N balls, if N is odd, the U could add one ball into box. The question is, how many turns will U and papa paly until the number of remained balls is 1?(taking away is 1 turn, adding ball is 1 turn)
input: 2
output:1

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值