Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A string S made of uppercase English letters is given. In one move, six letters forming the word BANANA ( one ' B ' ,

A string S made of uppercase English letters is given. In one move, six letters forming the word
"BANANA" (one 'B', three 'A's and two 'N's) can be deleted from S. What is the maximum
number times such a move can be applied to S?
Write a function:
function solution(S);
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 1.
Given S= "NAANAAXNABABYNNBZ", the function should return 2.
1
NAAXNABYNBZ
Given S= "QABAAAWOBL", the function should return 0.
Write an efficient algorithm for the following assumptions:
N is an integer within the range [1..100,000];
string S is made only of uppercase letters (A-Z).
Solution in typescript please. Thank you
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions