Question: public class Solution { static int findMinCost ( int n , int k , String s ) { int m = n / k; int
public class Solution
static int findMinCostint n int k String s
int m n k;
int totalCost ;
for int i ; i k; i
int charCount new int; Assuming lowercase English letters
for int j i; j n; j k
charCountscharAtja;
int maxCount ;
for int count : charCount
maxCount Math.maxmaxCount count;
totalCost m maxCount;
return totalCost;
public static void mainString args
int t ;
int n k;
String s "khkkdkuki";
System.out.printlnfindMinCostn k s; Output:
int n k;
String s "kegohsirj";
System.out.printlnfindMinCostn k s; Output:
i want this code in different way
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
