int (@NotNull CharSequence s1, @NotNull CharSequence s2) { int s1Length = s1.length(); int s2Length = s2.length(); if (s1Length == 0 || s2Length == 0) return 0; int i; for (i = 0; i < s1Length && i < s2Length; i++) { if (s1.charAt(s1Length - i - 1) != s2.charAt(s2Length - i - 1)) { break; } } return i; }