Maximum XOR Suffix
Updated
Problem statement
An array of n integers, arr, is given. Pick any index then calculate the XOR of the array from that index through the highest index. Append the value to the array. Repeat this process zero or more times. Determine the highest value possible.
Function
maximumValue(arr: int[]) → int
Complete the function maximumValue in the editor below.
maximumValue has the following parameter:
int arr[n]: the starting array
Returns
int: the maximum possible value in the array
Examples
Example 1
arr = [8, 2, 4, 12, 1]return = 14
Explantion is shwon in the image above pint 👆👆 The max strength possible is 14.
Example 2
arr = [1, 2, 3]return = 3Regardless of what index is chosen, the XOR value can never be greater than 3 :)
Constraints
- 1 ≤ n ≤ 105
- 0 ≤ arr[i] < 230
More TikTok interview questions
- Minimum Cost of Every K-Capable Model SetOA · Seen Nov 2026
- Longest Substring Without Repeating CharactersPHONE SCREEN · Seen Oct 2026
- Next Greater Indices and Maximum GapPHONE SCREEN · Seen Oct 2026
- Count Subarrays with at Least K Equal-Fruit PairsOA · Seen Oct 2026
- Shell Command Counts with History ReferencesOA · Seen Oct 2026
- Count Subarrays Matching a Comparison PatternOA · Seen Sep 2026
- Product Minus Sum of DigitsOA · Seen Aug 2026
- Count 2x2 Submatrices by Black CellsOA · Seen Aug 2026
- Find All Local PeaksOA · Seen Aug 2026
- Count Case-Insensitive TripletsOA · Seen Aug 2026
Similar questions at other companies
- Minimum No-Repeat Segments After One Character RemovalSalesforce · OASalesforce interview questions
- Minimize the Maximum Array ElementChubb · OAChubb interview questions
- Minimum Operations to Reduce an Integer to ZeroMicrosoft · OAMicrosoft interview questions
- Minimum Halvings for Alternating ParityIBM · OAIBM interview questions
- Server SelectionPoint72 · OAPoint72 interview questions
- Minimum Servers for an Exact LoadJP Morgan Chase · OAJP Morgan Chase interview questions
- Minimum Operations To Reduce To ZeroUber · OAUber interview questions
- Maximize PartitionsAmazon · OA
- Minimum Power-of-Two AdjustmentsNVIDIA · OANVIDIA interview questions
- Fewest Steps to Build an Array from ZerosExpedia · OAExpedia interview questions
TikTok interview experiences
- TikTok AI Infra Intern LLM Round 2: 1 Experience
- TikTok AI Infra Intern DeepSpeed Round: 1 Experience
- TikTok AI Infra Intern Kernel Round: 1 Experience
- TikTok AI Infra Intern Interviews, 3 Rounds: 1 Experience
- TikTok AI Infra Intern Interview Timeline: 1 Experience
- TikTok AI Infra Intern Onsite Round 2: 1 Experience