Company-style OA practice sets with full problem statements, sample test cases, and solutions.
Have you recently taken Uber's Online Assessment or coding test? Share the questions, test cases, or assessment patterns you encountered. Earn SWE180 Coins for every verified submission and use them to unlock other company OA sets and premium tools for free!
Given an array arr of n integers, for a triplet of 1-based indices i[1], i[2], i[3] (1 <= i[1] <= i[2] <= i[3] <= n + 1),
grossValue(i[1], i[2], i[3]) = sum[1, i[1]) - sum[i[1], i[2]) + sum[i[2], i[3]) - sum[i[3], n + 1)
Here, sum[l, r) (1 <= l <= r <= n + 1) uses half-open interval notation. It means that the interval includes index l but is exclusive of index r. In the special case where l = r, sum[l, r) is 0, and arr[l, r) is empty.
Find the maximum gross value of any valid triplet.
Example 1
Input
4 -5 3 9 4
Output
21
Explanation
arr = [-5, 3, 9, 4]. For triplet i[1] = 1, i[2] = 2, i[3] = 5:
- sum[1, 1) = 0
- sum[1, 2) = -5
- sum[2, 5) = 3 + 9 + 4 = 16
- sum[5, 5) = 0
grossValue = 0 - (-5) + 16 - 0 = 21 (maximum possible).
Example 2
Input
4 -1 1 -2 -2
Output
6
Explanation
Optimal indices yield gross value 6.
A string must be transferred using a custom network protocol. The protocol processes the string as follows:
- Each pair of characters in the string is processed together.
- If any pair contains matching characters (e.g., 'aa', 'bb'), it requires an additional sameTime seconds.
- The string can be split into substrings before transmission, with each partition cut adding partitionTime seconds.
Calculate the minimum possible total extra time required, which is the sum of:
- Time for processing pairs with matching characters.
- Time for creating partitions.
Example 1
Input
4 1 abcabcc
Output
5
Explanation
Two optimal approaches exist:
1. Split into ["abc", "abcc"]: partitionTime = 4, matching pairs in "abcc" = 1 ('cc') * 1 = 1. Total = 4 + 1 = 5.
2. Keep as single string ["abcabcc"]: 0 partition cuts, 5 matching pairs ('aa', 'bb', 'cc', 'cc', 'cc') * 1 = 5. Total = 5.
Gain complete transparency into the Uber online assessment process. Prepare effectively with real, verified coding challenges, test patterns, and platform details.
Wondering what top companies are actually asking in their initial screening rounds? We provide exact Data Structures, Algorithms, and logical reasoning questions reported by candidates who recently took the Uber online tests. Stop guessing and start practicing the right problems.
Understand exactly how many questions to expect, the typical time limits, and the platforms used (e.g., HackerRank, Codility, CodeSignal). Knowing the format in advance is the first step to clearing the Uber OA.