Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя newbie_se_bhi_noob

Автор newbie_se_bhi_noob, история, 3 года назад, По-английски

Problem My solution is here and my approach was first I was finding the sum of digits, then smallest digit we have to add will be (9-sum)%9 and that correct Tim William did it too!.

Now I'm finding the position where I want to add that single character. For position, logic is as follows If the wanted digit is less than all digits present in the string then put it before the smallest number. for eg., if the string is 5 I will put 4 before 5 and will be 45.

Now for wanted digit larger than digits present in the string, I will put it next to the smallest present in the string for eg 12121 then I will put 2 at last and it will be 121212. Then where is logic incorrect can someone give me a test case.

I tested for test cases as follows: 6
5
33
12121
55
19
90
and result were as follows :
Case 1: 45
Case 2: 333
Case 3: 121212
Case 4: 558
Case 5: 189
Case 6: 90

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится