👏Beats 73.67% of users with Java || Easy & Simple HashMap Approach 🔥💥
Intuition\nMake a Hashmap as a hm and store the all element\'s frequency and check if any element\'s frequency is more than 2 then return false, else return tru
# Intuition\nMake a Hashmap as a hm and store the all element\'s frequency and check if any element\'s frequency is more than 2 then return false, else return true.\n\n# **I Think This can Help You**\n![Screenshot 2024-03-01 105912.png](https://assets.leetcode.com/users/images/51ae9c23-a1aa-46dd-85f9-b2bc0b25f10f_1709279419.872309.png)\n\n\n# Approach\n1. Make Hashmap as a hm.\n2. Iterate over the array & check if element is exist in the hashmap just increase the frequency. if element is not exist just add element in hashmap & frequency as a 1.\n3. After that just check any element have a frequency more than 2 and if any element is have a frequency more than 2 then return false else return true.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\n- O(n)\n\n# Code\n```\nclass Solution {\n    public boolean isPossibleToSplit(int[] nums) {\n        HashMap<Integer,Integer> hm = new HashMap<>();   //  Make Hashmap as a hm.\n        for(int i=0;i<nums.length;i++){   // Iterate over the array & check if element is exist in the hashmap just increase the frequency. if element is not exist just add element in hashmap & frequency as a 1.\n            if(hm.containsKey(nums[i])){\n                hm.put(nums[i],hm.get(nums[i])+1);\n            }else{\n                hm.put(nums[i],1);\n            }\n        }\n        for(int i=0;i<nums.length;i++){   // After that just check any element have a frequency more than 2 and if any element is have a frequency more than 2 then return false else return true.\n            if((hm.get(nums[i]))>2){\n                return false;\n            }\n        }\n        return true;\n    }\n}\n```\n\n![_085bdc98-250c-48eb-be5f-1881072b1219.jpeg](https://assets.leetcode.com/users/images/864c402c-4624-40ab-a9fb-9bb67140963e_1709279428.8169365.jpeg)\n
['Array', 'Hash Table', 'Counting', 'Java']