Company: IDFC First Bank

Difficulty: medium

Problem Statement

Minimum Time to Cook Two Dishes Each chef is of type `A`, `B`, or `C`, with a required cooking time. An `A` chef can cook only dish A, a `B` chef only dish B, and a `C` chef can cook both dishes alone. Only one chef may work at a time. Choose either one `C` chef, or one `A` chef and one `B` chef. Print the minimum total time, or `-1` if neither choice is possible. Input Format The first line contains `n`. Each of the next `n` lines contains a type (`A`, `B`, or `C`) and a positive integer time. Output Format Print the minimum time. Constraints `1 <= n <= 100000`, and each time is at most `10^9`. Examples 5 A 2 B 5 A 2 C 4 B 3 Output 4

More IDFC First Bank OA questionsInterview experiences