gujju_ben_ni_gamzzat # Bahu saras O(n) ma solution...
Intuition\n Describe your first thoughts on how to solve this problem. \nDarek character ni frequency par jau 6u and then check karu 6u ke ae character ni frequ
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nDarek character ni frequency par jau 6u and then check karu 6u ke ae character ni frequency jetli bija badha j characters ni frequency ne karvi hoi to su karvanu.\n\nSau pratham to tamare badha j characters ni frequecny ne calculate kari do and aene alag thi ek arraylist ma muki do... so you kind of get the hold of all the frequencies.\n\nEk min_del karine ek variable ne initalize kari do...\n\nHu su vicharu 6u ke f-k and f+k bane thai sake to case ne simplyfy karva mate tamare to [f,f+k] --> sudhin j karavni do and agar koi ni frequency is less than f to aene to akho j delete kari nakho\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nPachi have todarek charcter mate bija darek character ni frequency ne modify ka....aevi ritna modify karo ke ae banne no difference to tmaro k na j equal hoi...\nbasically apdee to aevu try kariye 6e ke agar freq_i = 4 ...then we are trying to do freq_j = [4, 4+k]\n\n1. so agar jo freq_j < freq_i => aena j na badha j characters ne delete karido...\n2. agar  Math.abs(freq_j- freq_i) > k => agar jo aemna vadhhe characters no difference is greater than k then we are going to delete the extra characters atle k sudhi to apde allow karisu ...\npachi aena pachi je pan hase ae to extra j kehvase ...= aene delete karvu padse.\n3. Math.abs(freq_i- freq_j) <= k  ---> aggar jo avu kaik hoi to to yar aa to valid j caes 6e nathi vandho avano..\n\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nTraverse through each and every character in the word...to get the count of frequency of each character...\n\n O(n) \n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nLet\'s assume all the characters are present.... then it is at max\n O(26) = O(1)\n\n# Code\n```\nclass Solution {\n    public int minimumDeletions(String word, int k) {\n        /* STEP 1 : First get the frequencies of each charaacter.... */\n        HashMap<Character, Integer> hm = new HashMap<>();\n        int n = word.length();\n        for (int i = 0; i < n; i++) {\n            char ch = word.charAt(i);\n            hm.put(ch, hm.getOrDefault(ch, 0) + 1);\n        }\n        System.out.println(" hm " + hm);\n        /*\n         * for each element go on and search... freq[j]-freq[i]> k => you\'ll have to\n         * delete these\n         * extra characters... freq[j]<freq[i] => akhuj delete kari nakho.. then check\n         * for all such number of deleteions\n         * for that element...\n         */\n        int min_del = n;\n        List<Integer> arr = new ArrayList<>(hm.values());\n        for (int i = 0; i < arr.size(); i++) {\n            int freq_i = arr.get(i);\n            int curr_del = 0;\n            for (int j = 0; j < arr.size(); j++) {\n                if (i == j) {\n                    continue;\n                }\n                int freq_j = arr.get(j);\n                System.out.println(" freq_i : " + freq_i + " freq_j : " + freq_j);\n                if (freq_j < freq_i) {\n                    System.out.println(" case 1");\n                    curr_del += freq_j;\n                } else if (Math.abs(freq_j - freq_i) > k) {\n                    System.out.println(" case 2");\n                    curr_del += Math.abs(freq_j - freq_i - k);\n                } else {\n                    System.out.println(" case 3 ");\n                    /*\n                     * it is a valid case so no need to worry.\n                     * => Math.abs(freq_j - freq_j) <= k\n                     */\n                }\n                System.out.println(" ---- " + " curr_del " + curr_del + " ---- ");\n            }\n            min_del = Math.min(min_del, curr_del);\n            System.out.println(" curr_del : " + curr_del + " min_del : " + min_del);\n            System.out.println("===============================");\n        }\n\n        return min_del;\n    }\n}\n```
['Java']