simple solution

  • 0
    class Solution {
        public String[] findRelativeRanks(int[] nums) {
            int[] rank = new int[nums.length];
            rank = nums.clone();
            String[] output = new String[nums.length];
            Map<Integer,Integer> map = new HashMap<Integer,Integer>();
            for(int i=nums.length-1;i>=0;i--){
            for(int i=0;i<nums.length;i++){
                if(map.get(nums[i])==1)      output[i]="Gold Medal";
                else if(map.get(nums[i])==2) output[i]="Silver Medal";
                else if(map.get(nums[i])==3) output[i]="Bronze Medal";
                else output[i]=map.get(nums[i])+"";
            return output;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.