Question: Need help with Python code for best performance 1 . CountBananas Calculate how many times you can print the word BANANA using the letters given
Need help with Python code for best performance
CountBananas Calculate how many times you can print the word "BANANA" using the letters given in string S
Task description
A string S made of uppercase English letters is given. In one move,six letters forming the word "BANANA" one B three As and two Ns can be deleted from S What is the maximum number times such a move can be applied to S
Write a function:
function solutionS: string: number;
that, given a string S of length N returns the maximum number of moves that can be applied.
Examples:
Given S "NAABXXAN", the function should return
NAABXXAN
Given S "NAANAAXNABABYNNBZ", the function should return
NAANAAXNABABYNNBZ
NAAXNABYNBZ
XBYNZ
Given S "QABAAAWOBL", the function should return
QABAAAWOBL
Write an efficient algorithm for the following assumptions
N is an integer within the range ; string S is made only of uppercase letters AZ
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
