Untitled

 avatar
unknown
plain_text
3 years ago
1.0 kB
2
Indexable
package com.company;

import java.util.HashMap;

public class Main {

    public static void main(String[] args) {
	// write your code here
        String[] t = new String[]{"aba","cd"};
        System.out.println(test(t));
    }
    public static String test(String[] A){
        float min_prop = 1;
        for(int i=0;i<A.length;i++){
            HashMap<Character,Integer> map = new HashMap<>();
            float max_fr = -1;
            String str = A[i];
            for(int j=0;j<str.length();j++){
                char ch = str.charAt(j);
                map.put(ch,map.getOrDefault(ch,0)+1);
                int fr= map.get(ch);
                if(fr > max_fr){
                    max_fr=fr;
                }
            }
            float prop = max_fr/str.length();
            System.out.println("float here is " + prop );
            if(prop < min_prop){
                min_prop = prop;
            }
        }
        return Float.toString(min_prop);
    }
}
Editor is loading...