Values That Appear Twice
Updated
Problem statement
You are given an array nums of length n. Every value is between 1 and n, and each value appears once, twice, or not at all.
Return the values that appear exactly twice, in increasing order. If no value appears twice, return an empty list.
Function
findTwice(nums: int[]) → List<Integer>Examples
Example 1
nums = [3,1,3,2,6,1]return = [1,3]There are 6 values, each from 1 to 6. The value 3 appears at positions 0 and 2, and 1 at positions 1 and 5; 2 and 6 appear once, and 4 and 5 not at all. In increasing order the answer is [1,3].
Example 2
nums = [2,1]return = []Both values appear once (n = 2, values 1 and 2), so nothing appears twice: [].
Example 3
nums = [2,2]return = [2]Both values are 2, so 2 appears twice: [2].
Constraints
1 <= n == nums.length <= 10^41 <= nums[i] <= n- Each value appears at most twice
More Adobe Phone Screen questions
- Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
- All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
- Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
- Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
- Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
- Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
- Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026
Similar questions at other companies
- Insert Delete GetRandom O(1)Charta Health · PHONE SCREENCharta Health interview questions
- Filter, Sort, and Deduplicate Scheduled TasksRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
- Longest Consecutive SequenceKotak Mahindra Bank · PHONE SCREENKotak Mahindra Bank interview questions
- Longest Consecutive SequenceJP Morgan Chase · PHONE SCREENJP Morgan Chase interview questions
- Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
- Logger Rate Limiter with Every-Arrival HistoryGoogle · PHONE SCREENGoogle interview questions
- Propagating Fraud DetectorAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
- Top K Frequent Elements with a Recency TiebreakSwiggy · PHONE SCREEN
- Order and Batch Open-Close LifecycleHudson River Trading · PHONE SCREENHudson River Trading interview questions
- Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions