subject

Given a string, construct a new string by rearranging the original string and deleting characters as needed. Return the alphabetically largest string that can be constructed respecting a limit as to how many consecutive characters can be the same. Example:
s='bacc'
k=2
The largest string, alphabetically, is 'cccba' but it is not allowed because it uses the character 'c' more than 2 times consecutively. Therefore, the answer is 'ccbca'.
Function Description
Complete the function getLargestString in the editor below.
getLargestString has the following parameters:
string s[n]: the original string
int k: the maximum number of identical consecutive characters the new string can have
Returns:
string: the alphabetically largest string that can be constructed that has no more than k identical consecutive characters
Constraints
- 1<= n <= 10^5
- 1<= k <= 10^3
- The string s contains only lowercase English letters.
Input Format For Custom Testing
Sample Case 0
Sample Input
STDIN Function

zzzazz --> string s = 'zzzazz'
2 --> k = 2
Sample Output
zzazz
Explanation
One 'z' must be removed so that no more than 2 consecutive characters are the same.

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 09:30, relic7391
Is a string of code written to hurt others by damaging or destroying
Answers: 1
image
Computers and Technology, 22.06.2019 11:00, terriblexsiren
You receive an email from an impressive-sounding stranger, professor alexander rothschild renard iii, president of the american institute for scientific political statesmen. he urges you to vote for his presidential candidate choice. this social media red flag is known as
Answers: 1
image
Computers and Technology, 22.06.2019 20:00, ksanchez2100
Need asap assignment directions: think of an organization (business, religious institution, volunteer organization, sports team) with which you have been involved. imagine outfitting it with an it infrastructure. prepare a plan for what you would do to support outfitting it. draw a map of a network connecting all the individuals, give them pcs and printers, and lay out the design as best you can. the purpose is to begin working with these concepts, not to build a perfect network.
Answers: 2
image
Computers and Technology, 22.06.2019 22:00, mrnotsosmart744
Discuss the ways in which electronic information associated with payments is addressed in terms of security. include encryption, secure sockets layers, and secure electronic transactions in your discussion. are there any other ways that consumers and businesses can keep their payment information secure in an electronic commerce environment? do you feel that your information is safe when conducting electronic business? why or why not?
Answers: 1
You know the right answer?
Given a string, construct a new string by rearranging the original string and deleting characters as...

Questions in other subjects:

Konu
Chemistry, 23.02.2021 09:40
Konu
Social Studies, 23.02.2021 09:40