is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
The basic idea of the algorithm :
1. Start from the end of the string
2. Check for the edge cases, i.e., the string starts with ')' or ends with '('
3. Maintain two stacks -- one for the closing braces - ')' and one for the star '*'
4. If the character in the string is ')' push it in the closeBrace stack
5. If the character in the string is '*' push it in the star stack
6. If the character in the string is '(', the following cases need to be considered :
--- If both the star and closeBrace stacks are empty, return false
--- If the closeBrace stack is not empty, pop an item from closeBrace
--- If the star stack is not empty, pop an item from star
7. At the end, we keep popping from star and closeBrace stacks until any one of them is empty
8. If closeBrace stack is not empty, this means the parantheses are not balanced, we return false
9. For other cases, we return true
Time complexity : O(n), space complexity : O(n)
- skeeter November 08, 2017