package main;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;

class StringAnalyser {

    static Boolean isUnique(String s) {
        HashSet<Character> dict = new HashSet<>();
        for (int i = 0; i < s.length(); i++) {
            if (dict.contains(s.charAt(i))) return false;
            dict.add(s.charAt(i));
        }
        return true;
    }

    static Boolean isUniqueAscii(String s) {
        if (s.length() > 128) return false;
        boolean[] asciiMask = new boolean[128];

        for (int i = 0; i < s.length(); i++) {
            int val = s.charAt(i);
            if (asciiMask[val]) return false;
            asciiMask[val] = true;
        }
        return true;
    }

    static Boolean isPermutation(String first, String second) {
        if (first.length() != second.length()) return false;

        HashMap<Character, Integer> hf = countChars(first);
        HashMap<Character, Integer> hs = countChars(second);
        return hf.equals(hs);
    }

    private static HashMap<Character,Integer> countChars(String s) {
        HashMap<Character, Integer> res = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            Character c = s.charAt(i);
            if (res.containsKey(c)) {
                res.put(c, res.get(c) + 1);
            } else {
                res.put(c, 1);
            }
        }
        return res;
    }

    static String uRLifySpaces(char[] arr, int trueLength) {
        int spaces = countSpaces(arr, trueLength);
        int id = trueLength + 2 * spaces;
        for (int i = trueLength - 1; i >= 0; i--) {
            if (arr[i] == ' ') {
                arr[id-1] = '0'; arr[id-2] = '2'; arr[id-3] = '%';
                id -= 3;
            } else {
                arr[id - 1] = arr[i];
                id--;
            }
        }
        return new String(arr);
    }

    private static int countSpaces(char[] arr, int length) {
        int counter = 0;
        for (int i = 0; i < length; i++) {
            if (arr[i] == ' ')
                counter += 1;
        }
        return counter;
    }

    static Boolean isPalindromeOfPermutation(String string) {
        string = string.toLowerCase().replaceAll("\\s+", "");
        Iterator it = countChars(string).entrySet().iterator();
        int numbOfOdd = 0;
        while (it.hasNext() && numbOfOdd < 2){
            if ((int)((Map.Entry) it.next()).getValue() % 2 == 1) numbOfOdd += 1;
        }
        return numbOfOdd < 2;
    }

    static Boolean isPermittedEditOperation(String s1, String s2) {
        return false;
    }
}

@@ -29,90 +29,44 @@
 til.
-HashMap;%0Aimport java.util.HashSet;%0Aimport java.util.Iterator;%0Aimport java.util.Map
+*;%0A%0Aimport static java.lang.Math.abs
 ;%0A%0Ac
@@ -2552,28 +2552,1043 @@
         
-return false
+if (abs(s1.length() - s2.length()) %3E 1) return false;%0A        int changeCounter = 0;%0A        changeCounter = calculateStringsDifferences(s1, s2, changeCounter);%0A        return changeCounter %3C 2;%0A    %7D%0A%0A    private static int calculateStringsDifferences(String s1, String s2, int changeCounter) %7B%0A        Set%3CMap.Entry%3CCharacter, Integer%3E%3E s1Count = countChars(s1).entrySet();%0A        HashMap%3CCharacter, Integer%3E s2Count = countChars(s2);%0A        for (Map.Entry%3CCharacter, Integer%3E el : s1Count) %7B%0A            changeCounter += calculateElementDifferences(s2Count, el);%0A        %7D%0A        return changeCounter;%0A    %7D%0A%0A    private static int calculateElementDifferences(HashMap%3CCharacter, Integer%3E stringElements, Map.Entry%3CCharacter, Integer%3E toCompare) %7B%0A        int changeCounter = 0;%0A        if (stringElements.containsKey(toCompare.getKey())) %7B%0A            changeCounter += abs(toCompare.getValue() - stringElements.get(toCompare.getKey()));%0A        %7D else %7B%0A            changeCounter++;%0A        %7D%0A        return changeCounter
 ;%0A    %7D%0A

Add the solution for task 1.5. It works for linear time and use linear space.