Skip to content

Apple Coding Questions - DSA Problems & Solutions

Practice Apple placement paper coding questions with detailed solutions. Access Apple OA coding problems in Swift, C++, Python.

This page contains Apple coding questions from Apple OA placement papers with detailed solutions.

Apple OA Coding Section:

  • Problems: 2 coding problems
  • Time: 60 minutes
  • Languages: Swift, C++, Python, Objective-C
Q1: Find indices of two numbers that add up to target.

Solution (Swift):

func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
var map: [Int: Int] = [:]
for (index, num) in nums.enumerated() {
let complement = target - num
if let complementIndex = map[complement] {
return [complementIndex, index]
}
map[num] = index
}
return []
}

Time Complexity: O(n)


Practice Apple coding questions regularly!