The question is:
Take a list containg only strings. Now, take a string input from user and rearrange the elements of the list according to the number of occurence of the string taken from user in the elements of the list.
E.g.-LIST : ["no bun","bug bun bug bun bug bug","bunny bug","buggy bug bug buggy"]
STRING TAKEN : "bug"
OUTPUT LIST:["bug bun bug bun bug bug","buggy bug bug buggy","bunny bug","no bun"]
In this example, the string taken as input is “bug”. So, we have to rearrange the every element of the list according to the number of occurrence of the string “bug” in them.
"bug bun bug bun bug bug" → Number of times “bug” appears is 4 (maximum times). So, it will be the first element in the arranged list.
"buggy bug bug buggy" → Number of times “bug” appears is 2. So, it will be the second element in the arranged list.
Similarly proceed further.
New Questions |
---|
trustworthy online casino in New Zealand - C
|
SSM Exam - Other
|
SPC Exam - Other
|
SAFe-Practitioner Exam - Other
|
SAFe-Agilist Exam - Other
|
P_SAPEA_2023 Exam - Other
|
POPM Exam - Other
|