Question 1: Warehouse Robots with Threshold
Problem Description
At an Amazon warehouse, there are n robots used for handling inventory and package movement. Each robot has a threshold value stored in an array arr, where arr[i] represents the minimum condition required for the i-th robot to function.
Every robot can be assigned one of two states:
A configuration is considered valid if all robots satisfy the following conditions:
Given the array arr, determine the number of valid robot configurations possible.
Task
Return the total number of valid configurations.
Constraints
Each robot must be assigned exactly one state.
A configuration is valid only if no robot violates its condition.
Question 2: Most Common Product Pair
Problem Description
On Amazon e-commerce platform, customer purchase activity is recorded as transaction history. Each customer has a history of items they bought together across multiple orders. You are given a list of customers, where each customer's record contains a list of products bought together. Each trasaction represents products that were purchased together in a single order.
Example:
[('A', 'B', 'E'), ('C', 'D')]
[('A', 'E')]
[('C', 'B'), ('D', 'C')]
[('A', 'B')]
[('A', 'C')]Task
Return the pair of products that appears together most frequently across all transactions.
Rules
A pair consists of distinct products.
(A, B) and (B, A) are considered the same pair.
If multiple pairs have the same highest frequency, return the lexicographically smallest pair.
Notes
Duplicate items within a transaction should be counted only once.
Each transaction can contribute multiple pairs.