Question: HSBC Coding Round |Maximize Three-Digit Integer | Blog Sign Letters | Greedy Algorithms & String Frequency Maps | Feb 2nd Slot | Recent Online Assessment 2026
0
Entering edit mode

Task 1: Maximize Three-Digit Integer

Problem Statement:

Write a function solution that, given a three-digit integer N and an integer K, returns the maximum possible three-digit value that can be obtained by performing at most K increases by 1 of any digit in N.

Examples:

  1. Given N = 512 and K = 10, the function should return 972. The result can be obtained by increasing the first digit of N four times and the second digit six times.
  2. Given N = 191 and K = 4, the function should return 591. The result can be obtained by increasing the first digit of N four times.
  3. Given N = 285 and K = 20, the function should return 999. The result can be obtained by increasing the first digit of N seven times, the second digit once, and the third digit four times.

Assumptions:

  • N is an integer within the range [100..999].
    (Further constraints on K apply based on standard test cases).

 


Task 2: Maximize Blog Signs from Catalogue

Problem Statement:

There is a company that sells large letters made out of wood and metal (similar to the ones spelling "HOLLYWOOD"). The company is going out of business, and the owners want to sell off their remaining stock. They have listed all the remaining letters in a catalogue in a string S (in no particular order), and have advertised their "Everything must go" offer online.

Attracted by the reduced prices, Alice has decided to order some letters from the company. She wants to build as many signs with the name of her new blog as possible and place them around the city. She hasn't decided on the name of her blog yet, and is considering K different possibilities. Right now she is wondering about the maximum number of signs she can build if she chooses one of the names from her list.

Knowing the list of possible names of Alice's blog L and the company catalogue state S, find the maximum number of copies of a name from L that Alice can build.

Example Test Cases (from compiler output):

  1. Catalogue S = 'BILLOBILLOLLOBBI', Names L =
    ['BILL', 'BOB']
  2. Catalogue S = 'CAT', Names L =
    ['ILOVEMYDOG', 'CATS']
  3. Catalogue S = 'ABCDXYZ', Names L =
    ['ABCD', 'XYZ']
ADD COMMENTlink 6 hours ago Sarthak • 0

Login before adding your answer.

Similar Posts
Loading Similar Posts