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.
Soln:-
- ogephillip March 02, 20161) Get the key/value from dictionary.
2) Combine all values into 1 single array of letters.
3) Permutate the single array to get all letter combinations for input phoneNumber.
Code:-
-(void)allPossibileStrings:(NSArray*)inputs
{
NSDictionary* dict = @{@2: @[@"A", @"B", @"C"],
@3: @[@"D", @"E", @"F"],
@4: @[@"G", @"H", @"I"],
@5: @[@"J", @"K", @"L"],
@6: @[@"M", @"N", @"O"],
@7: @[@"P", @"Q", @"R", @"S"],
@8: @[@"T", @"U", @"V"],
@9: @[@"W", @"X", @"Y", @"Z"]};
NSMutableArray *combineLetters = [NSMutableArray array];
//Loop through phoneNumbers entered
for (NSNumber *num in inputs) {
//Get Value for each PhoneNumber from it's key
NSArray *letters = dict[num];
for (NSArray *tempArray in letters) {
//Get all letters and store in combineLettersArray
[combineLetters addObject:tempArray];
}
}
NSLog(@"The Combined Letter is %@", combineLetters);
//Get Permutation of letters from array
[self getPermutationFromInput:combineLetters];
}
//Permutation Function
- (void)getPermutationFromInput : (NSMutableArray *)inputArray {
NSMutableArray *permutation = nil;
for (int i = 0; i < inputArray.count; i++) {
if (!permutation) {
permutation = [NSMutableArray new];
for (NSString *character in inputArray) {
[permutation addObject:[NSArray arrayWithObject:character]];
}
} else {
NSMutableArray *aCopy = [permutation copy];
[permutation removeAllObjects];
for (NSString *character in inputArray) {
for (NSArray *tempArray in aCopy) {
if ([tempArray containsObject:character] == NO) {
NSMutableArray *newArray = [NSMutableArray arrayWithArray:tempArray];
[newArray addObject:character];
[permutation addObject:newArray];
}
}
}
}
}
NSLog(@"Permutation from Input is \n %@", permutation);
}
How to use Code:-
[self allPossibileStrings:@[@2,@4,@5]];
//In the Above the numbers on the keypads are 2,4 and 5.