write a program to find out suffix of two strings are same
Respostas da entrevista
Sigiloso
14 de fev. de 2018
Always remember suffix means not the last letter but all those matching letters counting backwards from the last letter.
Sigiloso
31 de ago. de 2018
Here is my solution for the same -
public static void commonSuffix(String s1, String s2) {
String res = "";
for(int i=s1.length()-1,j=s2.length()-1;i>=0 && j>=0;i--,j--) {
if(s1.charAt(i)==s2.charAt(j)) {
res = s1.charAt(i)+res;
}else {
break;
}
}
System.out.print(res);
}