Maximum Distinct Values After Swaps
Updated
Problem statement
You are given two integer arrays a and b and an integer k. In one operation, choose any index in a and any index in b, then swap those two elements.
Return the maximum possible number of distinct values in a after at most k operations.
Function
maximumDistinctAfterSwaps(a: int[], b: int[], k: int) → intExamples
Example 1
a = [1,1,2,2]b = [3,4,1,5]k = 2return = 4Swap one duplicate 1 and one duplicate 2 for 3 and 4. The first array then has four distinct values.
Constraints
1 <= a.length, b.length <= 2000000 <= k <= 200000-10^9 <= a[i], b[i] <= 10^9
More Akuna Capital Online Assessment questions
- Delivery Management SystemOA · Seen Nov 2026
- Count Server ReplacementsOA · Seen Nov 2026
- Match Orders by Price and Arrival TimeOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Maximum Remaining Drone PowerOA · Seen Nov 2026
- Rolling MetricsOA · Seen Oct 2026
- Vowel Substring GameOA · Seen Sep 2026
- Competitive ForagingOA · Seen Sep 2026
- Binary CircuitOA · Seen Sep 2026
- Items SortOA · Seen Sep 2026
- Minimize Malware Spread by Removing a NodeOA · Seen Sep 2026
Similar questions at other companies
- Min OperationAmazon · OA
- Min Cost to Complete All ProjectsSalesforce · OASalesforce interview questions
- Freelancing PlatformJP Morgan Chase · OAJP Morgan Chase interview questions
- Maximum Distinct Values After Cross-Array SwapsScale AI · OAScale AI interview questions
- Minimum Operations to Make a SubsequenceGoogle · OAGoogle interview questions
- Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
- Minimum Distinct Prefix CostChubb · OAChubb interview questions
- Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
- Rearrange Songs by AuthorZomato / Eternal · OAZomato / Eternal interview questions
- 🐘 Keep Them Apart 🦙QRT · OA
Akuna Capital interview experiences
- Akuna Capital Quant Trader and QR Interviews: 5 Experiences
- Akuna Capital JQR CodePair Rounds: 8 Experiences (Part 6 of 6)
- Akuna Capital QR Probability Phones: 14 Experiences (Part 5 of 6)
- Akuna Capital QR-ML Interviews: 11 Experiences (Part 4 of 6)
- Akuna Capital QR Regression Rounds: 11 Experiences (Part 3 of 6)
- Akuna Capital QR Coding Interviews: 17 Experiences (Part 2 of 6)