I had my interview scheduled from google. Received a mail to attend a mock test on a 3rd party platform. It won't affect my candidacy.
The questions were :
- Consider a social network with n users. You have been given vector<vector< int >> friends. where friends[i][0] and friends[i][1] are friends. A person 'a' can view profile of 'b' if he is friend or has a indirect common friend. Find out how many profiles can each user view.
Constraint :
n <= 10 ^ 5
friends.size() <= n
E.g. :
n = 7
friends = [{1,2}, {2,3}, {3,4}, {5,6}, {6,7}]
result = [4,4,4,4,3,3]
- Given a string 's' find the no. of unique palindromic substrings.
Constraints :
s.size() <= 5000
E.g. :
s = "aacaa"
result = 5 ["a", "c", "aa", "aca", "aacaa"]
I solved both of them. But am looking for an optimal soln. for 2nd question.
Comments (9)


