Domanda di colloquio di NMIMS

write a program to find out suffix of two strings are same

Risposte di colloquio

Anonimo

14 feb 2018

Always remember suffix means not the last letter but all those matching letters counting backwards from the last letter.

Anonimo

31 ago 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); }