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.
Looks like a simple Dynamic Programming problem. Start with a string of length 1. Initialize answer with 1 since 1 character can be a valid string. Add a new character to the string. If that character and the previous character together makes a valid string number (e.g. "23" but NOT "32") then add f(i-2) to the answer since this new 2-digit number permutes with those i-2 digits to create new valid combinations.
- Rohan Raja August 17, 2014No need to memoize in 1-d array since only two valid states are required.
bool isValidStringNumber(char*str, int st, int end)
{
if(end-st>2)
return false;
if((str[st]>'2' || str[st+1]>'6') && end-st==2)
return false;
return true;
}
int StringNumberSplit(char*str, int st, int end) // mapping 1->a, 2->b , ... 26->z
{
int prev = 1;
int prevprev = 1;
int ans = 1;
for(int i=1;i<end;i++)
{
ans = prev ;
if(isValidStringNumber(str,i-1, i+1))
{
ans = ans + prevprev;
}
prevprev = prev ;
prev = ans ;
}
return ans;
}