Smart keypad- advanced

I am not getting correct output , kindly let me know where my code went wrong, Here’s my code:

@Puneet_Sharma,
you are printing all the strings given to you.

Suggested approach:

This problem is almost the same as in smart keypad 1 problem ,i.e,
String table[]= { " ", “.+@$”, “abc”, “def”, “ghi”, “jkl” , “mno”, “pqrs” , “tuv”, “wxyz” }.

So in this question you need to print those strings (from search In array) that contain the strings generated by the alphabetical combination of number given as the input
Ex:- 34
3 => d,e,f
4 => g,h,i
So print all those strings that contain these combinations
dg, dh, di, eg, eh, ei, fg, fh, fi.

Also you only need to print strings from these only
string searchIn [] = {
“prateek”, “sneha”, “deepak”, “arnav”, “shikha”, “palak”,
“utkarsh”, “divyam”, “vidhi”, “sparsh”, “akku”
};

I have also used the same approach as you have suggested, I am checking that which of the elements belonging to the searchIn array are such that they contain the subsequences generated by the input string (34 in this case) and thus printing them, but I don’t know why all the elements are getting printed

I have also used the same approach as you have suggested, I am checking that which of the elements belonging to the searchIn array are such that they contain the subsequences generated by the input string (34 in this case) and thus printing them, but I don’t know why all the elements are getting printed.

@Puneet_Sharma,

https://ide.codingblocks.com/s/230355 corrected code.

@Puneet_Sharma,

You had a stray ’ ; ’ after the line:

				if (containsSub(searchIn[i], ans.get(j)))

Which was preventing your if statement from getting executed.