Skip to main content

Flipkart

Flipkart OA 2023 - Items Batch Analysis


Some items stored in a warehouse are either electronic or non-electronic. The electronic items are denoted by the vowels of the English alphabet: a, e, i, o, u. Non-electronic items are denoted by consonants from the alphabet.

The warehouse manager needs an application to transfer goods from the warehouse to sellers. The inventory is stored as a string where each character represents an item. The manager wants to sell items in batches of size K, following a first come first serve order. The goal is to determine the batch that contains the maximum number of electronic items.

Write an algorithm to help the manager find the batch containing the maximum 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.