Company: L&T Finance
Difficulty: medium
Find the Most Frequently Added Item in a Shopping Cart You are given a string items that consists of lowercase letters, digits, and a delimiter ; which represents a list of items in an online shopping cart separated by a delimiter (e.g., \",\" ). Calculate the most frequently occurring item. If there are more than one item with a maximum frequency, print the one that appears first in the string (the first item in the input that has a maximum frequency). Input Format The first line contains a string, items , the string of items. Output Format The function must return a STRING denoting the most frequent item. If there are multiple items with the same maximum frequency, then print the item which appears first in the string. Constraints 1 ≤ len(items) ≤ 10 5 Examples Input: orange;apple;apple Output: apple The most frequent item is apple . Input: laptop Output: laptop There is only one item laptop . Input: mobile;laptop;apple;apple;laptop Output: laptop There are two items with the maximum