Flipkart OA-6 2023
Problem Description
In a warehouse, items are categorized as either electronic or non-electronic. The electronic items are represented by the vowels in the English alphabet: a
, e
, i
, o
, u
. Non-electronic items are represented by any consonant.
The warehouse manager needs an application to facilitate the transfer of goods to sellers. The inventory is represented as a string where each character stands for an item. The manager wants to sell items in batches of size K
, following a first-in, first-out order. The task is to find the batch that contains the maximum number of electronic items.
Objective: Write an algorithm to identify the batch containing the highest number of electronic items.
Note:
The input/output is not case-sensitive. This means 'A' and 'a' are considered the same when identifying electronic items.
Input Format:
- The first line consists of a string item, representing the letters of the items (electronic/non-electronic).
- The second line consists of an integer wink, representing the batch size K that must be sold.
Output Format:
Print the total number of electronic devices in the batch that contains the maximum number of electronic items.
Example:
Input:
qwrtyuelws
4
Output:
3
Explanation:
In this case, the batch size is 4. We divide the string into batches:
- Batch 1: qwrt → 0 electronic items
- Batch 2: yuel → 3 electronic items (u, e)
- Batch 3: lws → 0 electronic items
The batch with the maximum electronic items is the second batch with 3 electronic items.
Thus, the output is 3.