春招第二面 乐信圣文 安卓开发

第一次面试字节草草结束,根本没到算法考察 - - 太菜了

面试官很亲切,也没为难我,纯粹我自己太菜

1. 大整数减法

没啥问题,面试官说主要是借位使用递归太消耗资源,应该使用循环

a = "10000"
b =  "789"
def is_bigger(a, b):
    if len(a) > len(b):
        return True
    elif len(a) < len(b):
        return False
    return a > b

def jiewei(a_list_reserve, index):
    
    if a_list_reserve[index] > 0:
        a_list_reserve[index] -= 1
        print(a_list_reserve)
    elif a_list_reserve[index] == 0:
        a_list_reserve[index] = 9
        print(a_list_reserve)
        jiewei(a_list_reserve, index+1)

def big_num_sub(a, b):
    if not is_bigger(a, b):
        raise "a <= b"
    a_list = list(map(int,a))
    b_list = list(map(int,b))
    a_list.reverse()
    b_list.reverse()
    result = []
    for i in range(min(len(a_list), len(b_list))):
        if a_list[i] >= b_list[i]:
            result.append(a_list[i] - b_list[i])
        else:
            jiewei(a_list, i + 1)
            result.append(a_list[i] + 10 - b_list[i])
    result.reverse()
    return result


if __name__=="__main__":
    re = big_num_sub(a, b)
    print(re)
    print(int(a) - int(b))

2.常规的动态规划算法考察

奈何我半年没写过动态规划了 - - ,写了个递归的,面试官同样说应该使用动态规划

count = 0

def is_next_last(m, n, i, j):
    if m == i and n == j:
        count += 1
    elif m == i or n == j:
        return
    else:
        is_next_last(m, n, i, j+1)
        is_next_last(m, n, i+1, j)
        

3.计算机网络基础 TCP和UDP的区别在哪,应用场景怎么样

4.操作系统有两种线程,分别是哪两种,有什么区别

两题都非常基础,奈何本人没准备过这些。。。。

反问有什么不足

面试官推荐我刷力扣常见题目,结合AI复习 计算机网络、操作系统、计算机组成原理的 常见面试题

面试官感觉真的一点为难我的意思的没有,纯粹是我太菜了

全部评论
佬,乐信二面了嘛
点赞 回复 分享
发布于 03-18 16:28 广东

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务