(String s, int k)
| 1 | class Solution { |
| 2 | public boolean canConstruct(String s, int k) { |
| 3 | int n = s.length(); |
| 4 | if(n < k) return false; |
| 5 | if(n == k) return true; |
| 6 | //find freq |
| 7 | int count[] = new int[26]; |
| 8 | for(int i=0;i<n;i++){ |
| 9 | count[s.charAt(i) - 'a']++; |
| 10 | } |
| 11 | int c=0; |
| 12 | //find odd count |
| 13 | for(int i=0;i<26;i++){ |
| 14 | if((count[i]&1)==1) c++; |
| 15 | } |
| 16 | return (c<=k); |
| 17 | } |
| 18 | } |
nothing calls this directly
no outgoing calls
no test coverage detected