package com.ykushch.prjalgo2.task4;

import java.util.Arrays;
import java.util.Collections;

public class DistanceRecursive {
    public static int computeEditDistance(String srcString, String destString) {
        int srcStrLen = srcString.length();
        int destStrLen = destString.length();

        if (srcStrLen == 0) {
            // insert all
            return destStrLen;
        }

        if (destStrLen == 0) {
            // remove all
            return srcStrLen;
        }

        char srcCharEnd = srcString.charAt(srcStrLen - 1);
        char destCharEnd = destString.charAt(destStrLen - 1);

        if (srcCharEnd == destCharEnd) {
            return computeEditDistance(srcString.substring(0, srcStrLen - 1), destString.substring(0, destStrLen - 1));
        }

        int insertOperationCounter = computeEditDistance(srcString, destString.substring(0, destStrLen - 1));
        int removeOperationCounter = computeEditDistance(srcString.substring(0, srcStrLen - 1), destString);
        int replaceOperationCounter = computeEditDistance(srcString.substring(0, srcStrLen - 1), destString.substring(0, destStrLen - 1));

        return 1 + Collections.min(Arrays.asList(insertOperationCounter, removeOperationCounter, replaceOperationCounter));
    }

    public static String findLongestCommonSequence(String src, String dest) {
        int srcLen = src.length();
        int destLen = dest.length();

        if (srcLen == 0 || destLen == 0) {
            return "";
        }

        char srcLastChar = src.charAt(srcLen - 1);
        char destLastChar = dest.charAt(destLen - 1);

        if (areLastCharsEqual(srcLastChar, destLastChar)) {
            return findLongestCommonSequence(src.substring(0, srcLen - 1), dest.substring(0, destLen - 1)) + src.charAt(srcLen - 1);
        } else {
            String x = findLongestCommonSequence(src, dest.substring(0, destLen - 1));
            String y = findLongestCommonSequence(src.substring(0, srcLen - 1), dest);

            return x.length() > y.length()
                    ? x
                    : y;
        }
    }

    private static boolean areLastCharsEqual(char srcLastChar, char destLastChar) {
        return srcLastChar == destLastChar;
    }
}

@@ -799,32 +799,19 @@
 t insert
-OperationCounter
+Cnt
  = compu
@@ -896,32 +896,19 @@
 t remove
-OperationCounter
+Cnt
  = compu
@@ -993,32 +993,19 @@
  replace
-OperationCounter
+Cnt
  = compu
@@ -1160,73 +1160,34 @@
 sert
-OperationCounter, removeOperationCounter, replaceOperationCounter
+Cnt, removeCnt, replaceCnt
 ));%0A
@@ -1657,24 +1657,44 @@
 srcLen - 1),
+%0A                   
  dest.substr

Change names