拼多多 算法工程师-20180921

1.数数看

拼多多 算法工程师-20180921_第1张图片

import re
from collections import Counter
#i buy an apple watch from the aPple store, by the way I also like eating apple.
if __name__ == '__main__':
    duan=input()
    duan=duan.lower()
    wordlist=re.split('[!-\?,;:\.\s]',duan)
    words=[word for word in wordlist if word is not '']
    tongji=Counter(words)
    #print(tongji.most_common())    
    tongji_words = tongji.most_common()
    n=len(tongji_words)
    for i in range(n):
        if i==n-1 or tongji_words[i][1]!=tongji_words[i+1][1]:
            break
    most_cnt_words = tongji.most_common(i+1)
    res = [t[0] for t in most_cnt_words]
    res.sort()
    ans = " ".join(res)
    print(ans)

2.缓存问题

拼多多 算法工程师-20180921_第2张图片

#include
#include
#include 
int add[10001];
int cun[1001];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;imax){
			max=double(cnt)/double(n);
			res=j;
		}
	}
	printf("%d\n",res);
	//system("PAUSE");
} 
//0 1 1 0 2 3 2 3

3.优惠券问题

拼多多 算法工程师-20180921_第3张图片

4.拆宝箱拿金币

拼多多 算法工程师-20180921_第4张图片

拼多多 算法工程师-20180921_第5张图片

#include
#include
#include
#include
using namespace std;
int main(){
	int M,A,R;
	cin >> M >> A >> R;
	vector dp(A+R+1,0);
	dp[0]=1;
	for(int i=0;i

 

你可能感兴趣的:(笔试)