// Path: src/main/java/com/hackerrank/SherlockAndTheValidString.java
// static String isValid(String s) {
//     Map<Character, Integer> dict = new HashMap<>();
//     for (Character c : s.toCharArray()) {
//         if (!dict.containsKey(c)) {
//             dict.put(c, 0);
//         }
//         dict.put(c, dict.get(c) + 1);
//     }
// 
//     int err = 0;
//     int val = dict.get(s.charAt(0));
//     for (Integer v : dict.values()) {
//         int abs = Math.abs(v - val);
//         if (abs == 1 || v == 1) {
//             err++;
//         }
//         if (err > 1 || abs > 1 && v > 1) {
//             return "NO";
//         }
// 
//     }
//     return "YES";
// }


import org.junit.Test;
import static com.hackerrank.SherlockAndTheValidString.isValid;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
package com.hackerrank;



public class SherlockAndTheValidStringTest {

    @Test
    public void shouldBeValid() {
// Path: src/main/java/com/hackerrank/SherlockAndTheValidString.java
// static String isValid(String s) {
//     Map<Character, Integer> dict = new HashMap<>();
//     for (Character c : s.toCharArray()) {
//         if (!dict.containsKey(c)) {
//             dict.put(c, 0);
//         }
//         dict.put(c, dict.get(c) + 1);
//     }
// 
//     int err = 0;
//     int val = dict.get(s.charAt(0));
//     for (Integer v : dict.values()) {
//         int abs = Math.abs(v - val);
//         if (abs == 1 || v == 1) {
//             err++;
//         }
//         if (err > 1 || abs > 1 && v > 1) {
//             return "NO";
//         }
// 
//     }
//     return "YES";
// }


// Path: src/test/java/com/hackerrank/SherlockAndTheValidStringTest.java
import org.junit.Test;
import static com.hackerrank.SherlockAndTheValidString.isValid;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;

package com.hackerrank;



public class SherlockAndTheValidStringTest {

    @Test
    public void shouldBeValid() {
        assertThat(isValid("aabbcc")).isEqualTo("YES");