Smash the Bricks
Updated
Problem statement
Bricks are numbered from 1 through newtons.length. A small hammer needs newtons[i] blows to destroy brick i+1. A big hammer destroys any brick in one blow and may be used at most bigHits times.
Minimize the total number of blows. If several choices have the same minimum, use the big hammer on as many bricks as the limit permits.
Return three rows: [[totalBlows], [big-hammer indices], [small-hammer indices]]. Each index row is sorted in ascending order. If a hammer is unused, its row is [-1].
Function
smashTheBricks(bigHits: int, newtons: int[]) → long[][]Examples
Example 1
bigHits = 0newtons = [2]return = [[2],[-1],[1]]No big-hammer blows are allowed. The small hammer needs two blows for brick 1.
Example 2
bigHits = 4newtons = [3,2,5,4,6,7,9]return = [[13],[3,5,6,7],[1,2,4]]Use the big hammer on the four strongest bricks at indices 3,5,6,7, costing four blows. The other bricks cost 3+2+4=9 small-hammer blows, for a total of 13.
Constraints
- 1 <= newtons.length <= 200000.
- 0 <= bigHits <= 200000.
- 1 <= newtons[i] <= 10^9.
- The values in newtons are distinct.
Source note: Original OA task images and any included source example. The practice contract follows the rules stated in the problem and source note.
More Adobe Online Assessment questions
- Base Unit ConversionsOA · Seen Nov 2026
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Top-Funded Villages and ProjectsOA · Seen Aug 2026
- Count Parent Nodes With a Target SumOA · Seen Aug 2026
- Largest Binary Number by ConcatenationOA · Seen Aug 2026
- Count Events by CategoryOA · Seen Aug 2026
- Graph M-ColoringOA · Seen Aug 2026
- Hall of Shifting TilesOA · Seen Aug 2026
- K-th Ancestor Subtree Preorder QueryOA · Seen Aug 2026
- Maze ReachabilityOA · Seen Aug 2026
Similar questions at other companies
- Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
- Minimum Cost K-Capable ModelsMicrosoft · OAMicrosoft interview questions
- Maximum Distinct Values After Unit AdjustmentsBirla Pivot · OA
- Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
- Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
- Maximize Minimum Deployment DifficultyJP Morgan Chase · OAJP Morgan Chase interview questions
- Latest Arrival to Catch a BusAutodesk · OAAutodesk interview questions
- Maximize Center A Package BenefitAmazon · OA
- EV Charging Cost OptimizationTata Consultancy Services · OATata Consultancy Services interview questions
- Maximize Workday EarningsCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
Adobe interview experiences
- Adobe New Grad OA: Unit Conversion and Code Review: 1 Experience
- Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
- Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
- Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
- Adobe New Grad MTS Interview Questions: 7 Experiences
- Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)