Time Complexity · #32 · 2026-05-06
What's the Big-O?
Go ·Difficulty 1/3
How to play
Read the code and pick its time complexity from four Big-O choices. Think about loops, recursion, and hidden costs. Press 1–4 or click to answer.
n = len(nums). What is the average-case time complexity?
package main
func twoSum(nums []int, target int) [2]int {
seen := make(map[int]int)
for i, v := range nums {
if j, ok := seen[target-v]; ok {
return [2]int{j, i}
}
seen[v] = i
}
return [2]int{-1, -1}
}
Loading your progress...
Press 1 through 4, or tap a numbered choice, to answer. Back to hub