Leetcode506
9比他大的只有10 排第二
3比他大的有 10 8 9 4
暴力解法 遍历一遍
Mapmap = new HashMap (); for(int i =0;i ){ //排第一位的 int biggerNum=0; for(int j=0;j ){ if(score[i]<score[j]){ biggerNum++; } } String index = String.valueOf(biggerNum+1); index= "1".equals(index)?"Gold Medal":index; index= "2".equals(index)?"Silver Medal":index; index= "3".equals(index)?"Bronze Medal":index; map.put(i,index); } return map.values().toArray(new String[0]);
nlogn解法:
暂未写出