Amazon SDE Full Time Role Interview Coding Problem India

894
Jan 10, 2025
Jan 10, 2025

I have never seen this problem anywhere before, I have solved this but would like to hear about your approach
Its a very interesting problem, and I think its safe to share now

Problem Statement -
*A conveyor belt at a recycling plant contains a sequence of bottles represented by the string:

'a' represents aluminum cans,
'b' represents glass bottles, and
'c' represents plastic containers.
The plant needs to collect at least k items of each type ('a', 'b', and 'c') for a complete recycling process.

Each minute, a worker can pick up either the leftmost or the rightmost item from the conveyor belt.

Determine the minimum number of minutes required for the worker to collect at least k items of each type.

If it is impossible to collect k items of each type, return -1.

Input:
A string conveyorbelt representing the sequence of bottles on the conveyor belt.
An integer k representing the minimum number of items of each type needed.

Output:
Return the minimum number of minutes required, or -1 if it is impossible.

Example:

Input:
Conveyor belt = "aabaaacaabc", k = 2

Output:
8
*
Interviewers keep interrupting constantly

I was not selected but now i have received and invitation for SDE-1 process wish me luck

Comments (4)