Round 1
Questions:
- Search in matrix (Revised)
You are given an 'm x n' matrix where each cell represents an alphabetical character (denoted by 'a' to 'z') or a wildcard character (denoted by '?').
Write a function 'search_in_matrix' to search string in the matrix that will have the following interface
Input
- targetString = String to be searched in the matrix of length minimum 0 to 100
- matrix = m x n matrix containing characters
Output
- 0, If you aren't able to find the given string
- 1, If you can find the given string
Constraints:
- You can move (right, left, down, or up)
- You can use a cell only once. You can't use the same cell to match different positions from the string
- You can replace a wildcard character with any character
Additional Constraints: 1xn.m 100
Input 1:
string : code Matrix a C O y b ? i fd k e m W X g e
Output 1: 1
Input 2:
string = "code" Matrix a C O y bf ? L i k e m W X g e
Output 2: 1
Execution time limit: 10 seconds
Round 2
Questions: For a string S, remove consecutive duplicate characters of even count.
E.g.
- Input: abbcbddd Output: acbddd
- Input: azxxzyyyddddyzzz Output: azzz
Candidate's Approach:
Candidate's Approach
The candidate initially struggled with the problem but later reattempted it and solved it in 45 minutes. The initial approach involved iterating through the string and counting consecutive characters, then removing them if their count was even.
After discussing with friends, the candidate optimized the solution to O(N) time complexity and O(N) space complexity using a stack to manage character counts.
Interviewer's Feedback
The interviewer was patient and provided guidance during the coding process. However, the candidate was unable to solve the problem during the interview.