[java] simple and easy code with explanation || Using HashMap || No priority queue
\nclass Solution {\n    public int[] maxSubsequence(int[] nums, int k) {\n        // we\'ll need hashmap because subsequence can\'t be formed without it.\n     
```\nclass Solution {\n    public int[] maxSubsequence(int[] nums, int k) {\n        // we\'ll need hashmap because subsequence can\'t be formed without it.\n        // If we\'ll just sort the array and find k largest from the array it will make a permutation not subsequence\n        \n        // Make a new array\n        int[] arr = new int[nums.length];\n        \n        // Store all the values of original array in the new array\n        for(int i = 0; i < nums.length; i++)\n            arr[i] = nums[i];\n        \n        // sort the new array\n        Arrays.sort(arr);\n        \n        // This hashmap will store k largest elements with their frequencies\n        HashMap<Integer, Integer> map = new HashMap<>();\n        for(int i = nums.length - 1; i > nums.length - k - 1; i--){\n            map.put(arr[i], map.getOrDefault(arr[i], 0) + 1);\n        }\n        \n        // Now we\'ll traverse the original array and store the elements one by one in the answer array(ans)\n        int ans[] = new int[k];\n        \n        // We\'ll keep on deleting elements from the hashmap once we found them in the original array\n        for(int i = 0, j = 0; i < nums.length; i++){\n            if(map.containsKey(nums[i])){\n                ans[j++] = nums[i];\n                if(map.get(nums[i]) == 1)\n                    map.remove(nums[i]);\n                else\n                    map.put(nums[i], map.get(nums[i]) - 1);\n            }\n        }\n        return ans;\n    }\n}\n```
['Sorting']