There were two questions.
Q 1. Given N and N elements Find the number of distinct sums. For example:
1, 2, 3
Possible sums of all subarrays: 1, 2, 3, 3, 5, 6. Return Value: 5 (Distinct sums are: 1, 2, 3, 5, 6)
Q 2. Given a string S, and a matrix M of characters. find if S exist in M or not.
a v f
g b e
c b e
Answer: (0, 0) (1, 1) (2, 0)
All 8 neighbors considered.
Solved 1st with 100% success, and in 2nd 14/16 cases were passing.
If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. In case you are prepared, test your skills using TCS, Wipro, Amazon and Microsoft Test Serieses.