You are given a binary string shipmentData consisting only of '0' and '1'.
A final string is built from a chosen ordering of shipmentData as follows:
- Start with an empty string
finalSequence. - For each character
cin the chosen ordering from left to right, appendctofinalSequence, then reversefinalSequence.
You may rearrange the characters of shipmentData arbitrarily before applying the operation. Return the rearranged shipmentData string that should be fed into the operation to produce the lexicographically maximum possible finalSequence.
Do not return finalSequence itself. The answer must be a rearrangement of the original shipmentData.
shipmentData = "0011" return = "0101"
The returned rearranged string is "0101". If this string is fed into the operation, the resulting final sequence is "1100", which is lexicographically maximum among all rearrangements.
shipmentData = "10100" return = "00101"
The final sequence reads positions 5,3,1,2,4 from the rearranged string. Placing the two '1' characters at positions 5 and 3 produces final sequence "11000".
shipmentData.length >= 1shipmentDatacontains only'0'and'1'.
- Count Promotional PeriodsOA · Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Get Minimum AmountOA · Seen Jun 2026
- Find Minimum CostOA · Seen Jun 2026
- Get Smallest Base SegmentOA · Seen Jun 2026
- Select Least Resource TasksOA · Seen Jun 2026
- Product Category Group SizesPHONE SCREEN · Seen May 2026
- Count Connected ComponentsPHONE SCREEN · Seen May 2026
public String rearrangeShipmentData(String shipmentData) {
// write your code here
}