Count Perfect Breaks
Updated
Problem statement
For a non-negative integer array arr of length n, arrays b and c form a perfect break when both have length n, every value is non-negative, b is non-decreasing, c is non-increasing, and b[i] + c[i] = arr[i] for every index.
Return the number of perfect breaks modulo 1,000,000,007.
Function
countPerfectBreaks(arr: int[]) → intExamples
Example 1
arr = [2,3,2]return = 4The four valid non-decreasing arrays b are [0,1,1], [0,1,2], [0,2,2], and [1,2,2]; each determines c = arr - b.
Constraints
1 <= arr.length <= 2000000 <= arr[i] <= 1000000
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
- Optimize Discount Selection Under a Point BudgetPalantir · OAPalantir interview questions
- Pressure-Isolation Shutdown OrderIntuit · OAIntuit interview questions
- Count Permutations Without Three Equal Parities in a RowGoogle · OAGoogle interview questions
- Count Good SubsequencesFlexport · OAFlexport interview questions
- Sum of Compressed Number for All SubarraysWells Fargo · OAWells Fargo interview questions
- Count Strictly Increasing Subsequences of Length 3IBM · OAIBM interview questions
- Winning Draws for a Mahjong HandZip · PHONE SCREENZip interview questions
- Coin Change IIApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
- Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions
- Largest Consistent Visiting GroupAuxoAI · OA