general programming skills
There are two arrays $a$ and $b$ each consisting of four strings. No two strings in each of the arrays are same. You have to tell whether the number of common strings in the arrays are more than or equal two or not.
This was an implementation problem. You iterate over the strings of one of the arrays (either $a$ or $b$, let us say $a$), and search whether the string is present in the other array (i.e. $b$) or not. Checking whether a string is a present in the array can be done by iterating over the elements of the array and comparing whether the element is equal to it or not. The below given pseudo code describes this.
There were total 200 test cases. Number of operations taken in solving a test case will be around 4 * 4 * (time taken in comparing two strings). As the length of the strings could be at max 10. So total time in each test case will be $4 * 4 * 10 = 160$ operations. Overall time considering the test cases will be $160 * 200 = 3 * 10^5$ which will comfortably run in a second. You can assume that usually you can make around $10^8$ operations in a second. Please check following blog of Triveni for such details which would be quite useful for beginners.
Some Implementation Related Details
In Java, there is an implementation related detail that you should take care. If you have two objects $s$, $t$ of String class, then you shouldn't check their equality by $s == t$ or not. This would be comparing the objects rather than comparing their content. You should use .equals() method, i.e. use s.equals(t). You can check this stack overflow link for more details about it.
This question is marked "community wiki".
asked 15 Apr, 22:10
C++ STL Solution:
We can use set of strings. Just insert all the 8 strings of both of the array and check it's size. if size <= 6, dishes are similar else they are dissimilar.
My Accepted Solution: https://www.codechef.com/viewsolution/13216452
answered 17 Apr, 18:34
I solved this problem using set in C++. link
answered 17 Apr, 22:43