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.
Here's an O(n) time, O(n) space solution.
Basic approach :
Dynamic programming.
For every '?' , we got two options : either fill a consonant , or a vowel and move forward. According to your previous choice, your prefix will change, i.e .
if you fill a consonant, your new function call will have c+1 consonants , and 0 vowels in the last streak.
so the recurrence boils down to two cases.
1. when its not a '?'
classify(startindex, consonants , vowels ) = classify(startindex + 1, consonants +1 , 0)
OR
classify(startindex, consonants , vowels ) = classify(startindex + 1, 0 , vowels + 1)
depending on whether the character at startindex is a consonant or a vowel.
2. when its a '?'
in this case , you need to check both cases, consonant and vowel
let c_val = classify(startindex+1 , consonant+1 , 0)
let v_val = classify(startindex+1 , 0 , vowel+1)
now the answer will be :
- if both c_val and v_val are good, then answer is good
- if both c_val and v_val are bad, then answer is bad
- the answer is mixed in all other cases
Here's the code(C++) :
}
- nilanjanalodh September 27, 2017