Equal Products
Learn this problemProblem statement
At one of Amazon’s busy warehouses, Team Alpha and Team Beta are assigned the task of processing n products for shipment. Each product handled by Team Alpha is labeled as inventory_alpha[i], and the corresponding product handled by Team Beta is labeled as inventory_beta[i].
For every product pair (inventory_alpha[i], inventory_beta[i]), Team Alpha is allowed to repeatedly perform the following operation on their product label:
Your task is to determine, for each product pair, whether Team Alpha can transform inventory_alpha[i] into inventory_beta[i] by performing the swap operation any number of times (including zero), while following these constraints:
The original problem asks to return bool[], but I modified it to int[]. 1 represents true, while 0 represents false.
Function
equalProducts(inventory_alpha: String[], inventory_beta: String[]) → int[]Examples
Example 1
inventory_alpha = ["abba"]inventory_beta = ["adda"]return = [1]
Example 2
inventory_alpha = ["azzel"]inventory_beta = ["apple"]return = [1]Constraints
- 1 ≤
n≤ 10^5 - 1 ≤ |
inventory_alpha[i]|, |inventory_beta[i]| ≤ 2*10^5 - |
inventory_alpha[i]| = |inventory_beta[i]| inventory_alpha[i]andinventory_beta[i]contain only lowercase Latin letters.- The sum of lengths of all strings in
inventory_alphaandinventory_betadoes not exceed 5 * 10^5
More Amazon problems
- Resolve Task DependenciesONSITE INTERVIEW · Seen Jul 2026
- Shortest Distance on a Circular Bus RouteOA · Seen Jul 2026
- Longest Increasing Subsequence With Bounded Adjacent DifferenceONSITE INTERVIEW · Seen Jul 2026
- Search in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Jul 2026
- Sliding Window MaximumONSITE INTERVIEW · Seen Jul 2026
- Merge IntervalsOA · Seen Jul 2026
- Sort Bug Report FrequenciesOA · Seen Jul 2026
- Drone Delivery RouteOA · Seen Jul 2026