public static int findMaxCommonSubstringLengthString str1 String str2 int prevRow = new intstr2length + 1; int currentRow = new intstr2length + 1; int maxLength = 0;
时间复杂度:假设str1的长度为m,str2的长度为n,那么外层循环会执行m次,内层循环会执行n次,所以总的时间复杂度为O(m*n)。
空间复杂度:算法中使用了两个长度为str2.length()+1的数组prevRow和currentRow,所以总的空间复杂度为O(n)。
原文地址: http://www.cveoy.top/t/topic/iHbT 著作权归作者所有。请勿转载和采集!