turing.com logo

Turing.com Interviews

1 experience10 reads
Turing.com OA Turing Question
turing.com logo
Turing.com
September 17, 202510 reads

Summary

I encountered this specific coding problem during my Online Assessment for Turing.com, which challenged me to construct the largest possible number given certain digit repetition constraints.

Full Experience

During the Online Assessment for Turing.com, I was presented with a fascinating algorithmic challenge. The goal was to rearrange the digits of a given number string to form the largest possible new number, but with a crucial constraint: no digit could appear continuously more than 'k' times. This problem required careful thought on how to balance maximizing the number while adhering to the repetition limit across the entire string, especially considering the large input size.

Interview Questions (1)

Q1
Maximize Number with Repetition Constraint
Data Structures & AlgorithmsHard

Given a number string num and an integer k, the task is to find the largest possible number that can be formed by rearranging the digits of num such that no digit appears continuously more than k times.

Example 1:

Input: num = "3391933", k = 3
Output: "9933313"
Explanation: largest possible number is "9933313", as you can see there is no continuous digit which is more than 3 times and largest number.

Example 2:

Input: num = "1121212", k = 2
Output: "221211"
Explanation: largest possible number is "221211", as you can see there is no continuous digit which is more than 2 times.

Constraints:

  • 1 <= k <= num.length <= 10^7
  • num consists of 0 to 9 digits.

Have a Turing.com Interview Experience to Share?

Help other candidates by sharing your interview experience. Your insights could make the difference for someone preparing for their dream job at Turing.com.