也不知道这算哪门子伪代码,意思比较明了 list<String,int> result=new ArrayList(); Map<String,int> countMap=new HashMap(); int size=5000; int mapRecordCount=0; int repeat=0;for each keyWord in KeyWords if countMap is full then result add top 10 records of countMap clear countBank set mapRecordCount =0 end if countMap not contains keyWord then countMap put keyWord,0 else get keyword repeat countMap put keyword,repeat+1 end if nextsor result by desc take top 10 as result return
list<String,int> result=new ArrayList();
Map<String,int> countMap=new HashMap();
int size=5000;
int mapRecordCount=0;
int repeat=0;for each keyWord in KeyWords
if countMap is full then
result add top 10 records of countMap
clear countBank
set mapRecordCount =0
end if countMap not contains keyWord then
countMap put keyWord,0
else
get keyword repeat
countMap put keyword,repeat+1
end if
nextsor result by desc
take top 10 as result return
最后时间复杂度就是nlgn