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.
k will always exist, 0<=k<=n
- adi.dtu March 24, 2017let's assume k was found at some position (denoted by |)
........|.....
now if a ( is added at the end, k remains the same since no. of )s on right half remain the same.
........|.....(
if a ) is added the end, then we have 1 extra ) on the right half, let's find the new k
if the immediate next bracket after the division (k+1 th bracket) was (, then sliding division partition by 1 position to the right balances the brackets again since no. of (s in left half also increases by 1 now.
........|(....) -> ........(|....)
if the immediate next bracket after the division (k+1 th bracket) was ), then sliding division partition by 1 position to the right balances the brackets again since no. of )s in right half also decreases by 1 now.
........|)....) -> ........)|....)
So, effectively if we have a given string and a k, appending a ) to the same string increases k by 1, appending ( to the same string doesn't change k.
Starting with an empty string, k = 0, start parsing the given string, for each ) ecnountered increase k by 1.
ans = no. of )s in the string