Single Element in a Sorted Array
Updated
Problem statement
A sorted array contains one value exactly once and every other value exactly twice. Return the single value in logarithmic time.
Function
singleNonDuplicate(nums: int[]) → intExamples
Example 1
nums = [1,1,2,3,3,4,4,8,8]return = 2Every value except 2 occupies one adjacent pair.
Constraints
1 <= nums.length <= 100000and the length is odd.- The array is sorted in non-decreasing order.
- Values fit in a signed 32-bit integer.
More Atlassian Online Assessment questions
- Planning ProductionOA · Seen Feb 2025
- K-Means ClusteringOA · Seen Feb 2025
- Minimum Sorted Erasure OperationsOA · Seen Jun 2024
- Count Analogous ArraysOA · Seen Mar 2024
- Get Maximum ScoreOA · Seen Mar 2024
- Better Compression 🦀OA · Seen Mar 2024
- Romanizer 🐡OA · Seen Mar 2024
- Flower Bouquets 💐OA · Seen Mar 2024
- Binary Search Tree IteratorOA · Seen Nov 2023
- Binary Tree Level Order TraversalOA · Seen Nov 2023
Similar questions at other companies
- Minimum Non-Adjacent Selection CapabilityMicrosoft · OAMicrosoft interview questions
- Count Lamps Lighting Each PointAirbnb · OAAirbnb interview questions
- Count Pairs of Overlapping SquaresCapital One · OACapital One interview questions
- Bank Accounts with Balance HistoryMeta · OAMeta interview questions
- Index of the Maximum After Left RotationsChubb · OAChubb interview questions
- Rolling MetricsAkuna Capital · OAAkuna Capital interview questions
- Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
- Linear InterpolatorTwo Sigma · OATwo Sigma interview questions
- Rock JumpingIMC Trading · OAIMC Trading interview questions
- Find Sum of BeautiesAmazon · OA