Company: Amazon_16feb

Difficulty: medium

Problem Statement

Count Wrapped Items Problem Description You are given a string S made up of lowercase English letters and digits, where the letters stand for items and the digits stand for packaging lines placed around them. An item (letter) counts as wrapped whenever the character immediately before it is a digit and the character immediately after it is also a digit. Find and return an integer giving the total number of such wrapped items. Input Specification input1 : A string S containing only lowercase English letters and digits (0-9). Output Specification Return an integer value representing the number of items wrapped in packaging lines. Examples Example 1: Input: input1 = "1a2b3c4d5" Output: 4 Explanation: Here, the string S is "1a2b3c4d5". We can find the wrapped items as below: 'a' between 1 and 2 'b' between 2 and 3 'c' between 3 and 4 'd' between 4 and 5 The count of such items is 4, hence 4 is returned as the output. Example 2: Input: input1 = "5aart6i7io8o5o56" Output: 3 Explanation: Here

More Amazon_16feb OA questionsInterview experiences