Can someone give a test case where my code fails or rather guide me to the correct approach ? After taking care of the last digit cases, I'm using a greedy approach to find the first number that on removal will lead to (sum of digits) %3=0 and has the next number greater than itself. If such a number doesn't exist, I remove the lowest rightmost number that will lead to that result. asked 28 Oct '17, 23:18

In your code on line 73: Consider this test case: Your Output Correct Output answered 28 Oct '17, 23:34

Can anyone tell me due to which testcase it was showing wrong answer? answered 29 Oct '17, 00:09
1
Input: Correct Output: Your Output:
(29 Oct '17, 00:22)
I'm noob in java so I can't help you with why your code gives no output but I can say that you've read the question wrong. I see you've taken input as integer which is wrong because the input constraint says that input number can be of 10^5 digits long i.e input number can be 10^(10^5) which your long int input can't handle. Try implementing using string. Hope it helps.
(29 Oct '17, 00:27)
thanks @a_d_i
(29 Oct '17, 00:28)
You're welcome bro.
(29 Oct '17, 00:44)

Can anyone give me a test case where my code fails? It's working well for all the test cases I checked. PLEASE HELP ME!!! I'm storing the digits in an array from one's place. Then I am iterating through all the digits and finding the new number by removing that particular digit. Now, I'm checking whether it is divisible by 6 or not and if it is then I check whether it is largest number possible which I initially set to 1. At last I'm printing the new number with k1 digits where k is the total number of digits in the initial number. Leading zeros will be printed since I used %0*d and passed k1 and maxnum to it. LINK: My Solution answered 29 Oct '17, 00:29
It would time out. The solution time complexity is O(N^2) which won't pass.
(29 Oct '17, 00:33)
Further, the number can have 10^5 digits, thus, can't be stored in int or even long long.
(29 Oct '17, 00:34)
But it's giving wrong answer
(29 Oct '17, 00:37)
n can be 100000 so it can only have a maximum of 6 digits right?
(29 Oct '17, 00:38)
n can have 100000 digits . So you can't store it in int
(29 Oct '17, 00:38)
But in constraints it is giving n>=2
(29 Oct '17, 00:39)
Ok @ramini , your output for 66666666666666666 is coming 1 which is wrong
(29 Oct '17, 00:45)
@spp___ There's no single digit input in this question. Read the constraints carefully.
(29 Oct '17, 00:46)
n= no.of digits the number has !!!!
(29 Oct '17, 00:50)
showing 5 of 9
show all

Try the following: 333966 => 33966 369369 => 69369 123456 => 12456 123126 => 12312 654321 => 65421 162132 => 16212 167137 => 17137 137167 => 17167 answered 29 Oct '17, 04:09
