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

I have doubt on Google KickStart's Round A 2022 Nine Challenge problem

Правка en1, от newbie_se_bhi_noob, 2022-03-28 12:04:24

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

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский newbie_se_bhi_noob 2022-03-28 12:04:24 1168 Initial revision (published)