Q1.
Lost Luggage Tracker
Story: At a major international airport, luggage scanning systems handle thousands of bags daily,
assigning IDs from 1 to n. Recently, a software malfunction caused one bag to be scanned twice
while another was completely missed, creating delays and confusion. To avoid these issues, airport
authorities need a system that analyzes the scanned luggage IDs and reports which bag ID is
missing and which one is duplicated. This helps baggage handlers quickly restore order and reduce
passenger frustration.
Constraints: 1 <= n <= 10^5, IDs are integers between 1 and n.
Sample Input: n = 5, arr = [1, 2, 2, 4, 5]
Sample Output: Missing = 3, Duplicate = 2
Explanation: Since 2 appears twice and 3 is missing, the output identifies them.
Topic Covered: Array Searching
Expected Complexity: Time: O(n), Space: O(1)
Q2. Missing Number Finder
Story: A software system manages user IDs sequentially from 1 to n. Due to a database error
during migration, one ID has gone missing, causing inconsistencies in access control and user
lookups. To maintain reliability, administrators need a quick method to find the missing ID without
multiple scans or sorting the entire dataset. Identifying this missing record ensures system security
and uninterrupted service.
Constraints: 1 <= n <= 10^5, IDs are integers between 1 and n.
Sample Input: n = 5, arr = [1, 2, 4, 5]
Sample Output: Missing = 3
Explanation: The sequence 1 to 5 is missing 3, hence result = 3.
Topic Covered: Array Math (Summation)
Expected Complexity: Time: O(n), Space: O(1)
Q3. Ice-Cream Sales Profit
Story: Throughout summer, an ice-cream vendor records daily profit and loss. Some days bring
profit while rainy or supply-issue days bring loss. To optimize operations, the vendor wants to
determine the longest consecutive set of days yielding the maximum total profit. This analysis helps
plan inventory and promotions during profitable streaks, improving overall revenue management.
Constraints: 1 <= n <= 10^5, profits/losses can be negative or positive.
Sample Input: arr = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
Sample Output: Max Profit = 6
Explanation: The subarray [4, -1, 2, 1] has the maximum sum = 6.
Topic Covered: Kadane’s Algorithm
Expected Complexity: Time: O(n), Space: O(1)