Ios developer Interview Questions |

Ios developer Interview Questions


ios developer interview questions shared by candidates

Top Interview Questions

Sort: RelevancePopular Date

Giving an array of numbers and an int, return true if is there any pair of numbers inside the array that summed is equal to the input int, otherwise return false.

5 Answers

-(void)findPair{ NSArray *array = @[@0,@4,@3,@3,@5,@1,@8,@2,@6]; int sum ; int input = 7; for(int i=0;i<[array count];i++) { for(int j=0;j!=i && j<[array count];j++) { { sum = [[array objectAtIndex:i] intValue] + [[array objectAtIndex:j] intValue]; if(sum == input) { NSLog(@"Pair found and values are %d and %d",[[array objectAtIndex:i] intValue],[[array objectAtIndex:j]intValue]); } } } } }

The above solution would be very slow. I suggest not square looping through the array because in case there is no pair your algorithm would have to loop it array.count^2 times. For example, if we have an array of 100 numbers and none of them builds up a pair you would have to iterate 10000 times. I would suggest looping the array just once but at every iteration to save a value by a key of its complement to the local dictionary and just check every time if there is a value by a key of the current number. In Swift it would look like this: func hasPair(array: [Int], input: Int) -> Bool { var complementDict = [Int : Int]() for int in array { if int <= input { if let complement = complementDict[int] { print("\(complement) + \(int) = \(input)") return true } let complement = input - int complementDict[complement] = int } } print("Did not found any pair") return false } And this is Obj-C version: -(BOOL)hasPairIn:(NSArray*)array for:(NSNumber*)input { NSMutableDictionary* complementDict = [NSMutableDictionary new]; for (NSNumber* num in array) { if (num <= input) { if (complementDict[num] != nil) { NSLog(@"%@ + %@ = %@", complementDict[num], num, input); return YES; } NSNumber* complement = [NSNumber numberWithInt:[input intValue] - [num intValue]]; complementDict[complement] = num; } } NSLog(@"Did not found any pair"); return NO; }

let arr = [0, 8, 15, 77, 88, 9] func hasTwoNumbersThatSum(to:Int, arr:[Int]) -> Bool { let numberSet = Set(arr) for num in numberSet { let otherNum = to - num if numberSet.contains(otherNum){ return true } } return false } print(hasTwoNumbersThatSum(to: 25, arr: arr))

How would you implement UIView hitTest mehtod?

3 Answers

Giving a circular sorted array Ex: [7,9,3,5,6], write an algorithm that finds the smaller element index.

3 Answers

One or more comments have been removed.
Please see our Community Guidelines or Terms of Service for more information.

Why do you think what Farmdrop is doing is important

1 Answer

Implement three different tasks in Swift: - An app to take pictures with the front camera - An app which moves textfields when keyboard appears - Another app which uses CoreData and updates a list from an endpoint

1 Answer

Q: What is Polymorphism?

1 Answer

Q: What are the Pillars of Object Oriented Programming?

1 Answer

Standard questions and silly and boring tech questions around app architecture. MVVM, MVC, VIPER, etc

1 Answer

Implement sliding programme grid app for iOS. Technical requirements were given, along with REST API of BBC 4 channel.

1 Answer

Core data, bridging header, how to configure private cocoa pods repository. Tdd, do you have experience with complex badly written code bases? And how do work with these. Are you willing to work with badly written code bases and follow tdd? They also ask some easy questions about properties and memory management.

1 Answer
110 of 126 Interview Questions