滴滴数分笔试
# 第一题
SELECT t.uid,
CASE WHEN A.level is null THEN 0 ELSE A.level END AS level,
CASE WHEN B.mileage is null THEN 0 ELSE B.mileage END AS mileage,
CASE WHEN C.complaint_cnt is null THEN 0 ELSE C.complaint_cnt END AS complaint_cnt
from
(select uid from A union select uid from B union select uid from C)t
left join A on t.uid=A.uid
left join B on t.uid = B.uid
left join C on t.uid=C.uid;
# 第二题
import collections
s=input().split(',')
count=collections.defaultdict(int)
str1=[]
# 初始化
for i in set(s):
count[str(i)]=0
for i in s:
count[str(i)]+=1
if count[str(i)]==1:
str1.append(str(i))
else:
str1.append(str(str(i)+'_'+str((count[str(i)]-2))))
print(str1)
s=input().split(',')
count=collections.defaultdict(int)
str1=[]
# 初始化
for i in set(s):
count[str(i)]=0
for i in s:
count[str(i)]+=1
if count[str(i)]==1:
str1.append(str(i))
else:
str1.append(str(str(i)+'_'+str((count[str(i)]-2))))
print(str1)
编程题开始的时候只要25min 以为自己要写不完了,还好还好。。。
#笔试题目##滴滴#