General iOS, CS questions and interview prep resources.
-
iOS Interview Questions for Senior Developers (useful even if you're not senior yet)
| // Write your code here | |
| func solve() { | |
| // know the cost of balloons | |
| let costOfBallons = getArray(readLine()!) | |
| // know the number of participants | |
| let numberOfParticipant = Int(readLine()!)! | |
| // some holder to capture who has solved the problem | |
| var firstParticipantSolved = 0 |
General iOS, CS questions and interview prep resources.
iOS Interview Questions for Senior Developers (useful even if you're not senior yet)
| func findIndexOf(targetSum sum: Int, in inputArray: [Int]) -> (Int,Int) { | |
| //Output index | |
| var indices: (Int,Int) = (-1, -1) | |
| //count of input array | |
| let inputArrayCount = inputArray.count | |
| for (index, eachElement) in inputArray.enumerated() { | |
| for sartIndex in index..<inputArrayCount { | |
| if eachElement + inputArray[sartIndex] == sum { |
| func findIndexOf(targetSum sum: Int, in inputArray: [Int]) -> (Int,Int) { | |
| // Output Indices | |
| var indices: (Int,Int) = (-1, -1) | |
| // hastable | |
| var hashTable = [Int:Int]() | |
| // enumerate it | |
| for (index, value) in inputArray.enumerated() { | |
| // check if hastable has complementry value (i.e index) | |
| if let rightIndex = hashTable[value] { | |
| indices.0 = index |
| import Foundation | |
| import Combine | |
| // MARK: - Error | |
| enum APIError: Error, LocalizedError { | |
| case unKnown | |
| case apiError(reason: String) | |
| } | |
| extension APIError { |
| func isvalidPasswordPolicy(_ password: String) -> Bool { | |
| // Output | |
| var isValidPasswordPolicy = false | |
| // Get the component of each password policy | |
| let components = password.components(separatedBy: CharacterSet.whitespaces) | |
| // From 1st component get the lower and upper bound | |
| let first = components[0].components(separatedBy: "-") | |
| guard let lowerBound = Int(first.first ?? "0") else { return isValidPasswordPolicy } |
| func isvalidPasswordPolicy(_ password: String) -> Bool { | |
| // Output | |
| var isValidPasswordPolicy = false | |
| // Get the component of each password policy | |
| let components = password.components(separatedBy: CharacterSet.whitespaces) | |
| // From 1st component get the lower and upper bound | |
| let first = components[0].components(separatedBy: "-") | |
| guard var lowerBound = Int(first.first ?? "0") else { return isValidPasswordPolicy } |
| // Problem: https://www.pramp.com/challenge/2WBx3Axln1t7JQ2jQq96 | |
| func findBusiestPeriod(data: [[Int]]) -> Int { | |
| var timeStamp = 0 | |
| var busiest = -1 | |
| var currentBusiest = 0 | |
| let length = data.count | |
| // MARK: Data Structure | |
| public class BinaryTreeNode<Element: Comparable> { | |
| weak var parent:BinaryTreeNode? | |
| var leftNode:BinaryTreeNode? | |
| var payload:Element | |
| var rightNode:BinaryTreeNode? | |