MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / Solution

Class Solution

MinimumLengthofStringAfterOperations.java:1–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Solution {
2 public int minimumLength(String s) {
3 // N + 26
4 int freq[] = new int[26];
5 int n = s.length();
6 for(int i=0;i<n;i++){
7 freq[s.charAt(i) - 'a']++;
8 }
9 int count=0;
10 for(int i=0;i<26;i++){
11 if(freq[i]>0){
12 if(freq[i]%2==0){
13 count+=2;
14 }else{
15 count+=1;
16 }
17 }
18 }
19 return count;
20 }
21}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected