1. 程式人生 > >騰訊社招筆試加面試

騰訊社招筆試加面試

筆試(每題40分鐘,不能除錯!!!):

  1. 輸出:
輸入n,輸出方陣,
n=5時如下
0   0   0   0   5   
0   0   0   6   4   
0   0   7   14  3
0   8   15  13  2
9   10  11  12  1

n=3時如下
0   0   3
0   4   2
5   6   1

始終調不對,望大佬解決,留下評論。

  1. 大整數減法
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ***************************************************************************
# # Copyright (c) 2017 ByteDance.com, Inc. All Rights Reserved # # *************************************************************************/ # # @file main.py # # @author [email protected] # @date 2018/5/12 # num = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] # a > b def string_dec(a, b): length
= max(len(a), len(b)) # 1234567 while (len(a) < length): # 補位 a = "0" + a # 0056778 while (len(b) < length): # 補位 b = "0" + b arr_a = list(a) arr_b = list(b) i = length - 1 while (i >= 0): # 從後到頭遍歷 sum = int(arr_a[i]) - int(arr_b[i]) if
sum < 0: # 小於0,借位 pos = i - 1 while (arr_a[pos] == '0'): # 0 -> 9 arr_a[pos] == '9' pos = pos - 1 arr_a[pos] = num[int(arr_a[pos]) - 1] sum = sum + 10 else: # 大於0,足夠減 pass arr_a[i] = num[(sum % 10)] i = i - 1 a = ''.join(arr_a) while (len(a) > 1 and a[0] == '0'): # 去掉字首0 a = a[1:] return a if __name__ == '__main__': a = '1334567' b = '56878' c = string_dec(a, b) print a,"-",b,"=",c

1面

  1. 工作經歷,業務背景。
  2. 演算法:如何獲取陣列最小k個數;陣列如何取出兩個數,他們的和為指定數值。
  3. 語言:Java HashMap 和ConcurrentHashMap
  4. 計算機網路:流量控制和擁塞控制
  5. 作業系統:select 和epoll 的區別
  6. golang 如何併發

2面

聊專案細節

3面