Panda Guru LogoPanda
Guru

Google L3 Onsite Interview Question

Round 1

Questions: You have been given a string s. Two strings s1 and s2 are considered to be magical string pairs if the number of distinct characters in s1 is equal to s2. Given a string s, find the number of triplets i, j, k which satisfy this condition. The string s1 is from s[i, j] and s2 from [j+1, k].

Candidate's Approach
  • Provided a brute force solution using set.
  • Offered an optimized solution using BitMask.
  • Received hints from the interviewer suggesting the use of Binary Search but was unable to fully implement it.
Interviewer's Feedback
  • The interviewer mentioned there is another efficient approach apart from BitMask.
  • Provided hints to guide the candidate towards using Binary Search.