October LunchTime UNofficial Editorials (First two problems) Revised

For the second question my solution is O(n) but still giving TLE, please look into this:- CodeChef: Practical coding for everyone

hey taran my code is giving wa in 1st subtask. any testcase where it might fail? yKzrA3 - Online C++ Compiler & Debugging Tool - Ideone.com

For the first question why is my solution giving WA in Subtask 2?

@vishaldugyala I guess u haven’t taken care of the fact that no.of digits may be different

Thanks Taran! Great job helping out others. Kudos!

Is erase function also linear in Time???

I think you can add something on how to avoid those leading zeroes. I was simple printing the array and wasted A HUGE CHUNK of my time because it was printing leading 0.

And BTW, I feel the problem statement SHOULD specify that leading zeroes arent allowed. I mean, yeah, to many people “5555+5555=0000” would make sense.

3 Likes

Thanks for the explanation :slight_smile:
Can you help me debugging my code for 2nd problem please? LINK

hey taran can u share your fb profile link or can you send me req.? Needed to talk to you personally. :slight_smile:

1 Like
t = int(input())
while t>0 :
    n = input()
    i = len(n)
    flag = 0
    li = []
    while i>0:
        copy = int(n[:i-1] + n[i:])
        if copy%6 == 0:
            li.append(copy)
            flag = 1
        i -= 1
    if flag == 1:
        print(str(max(li)).rjust(len(n)-1, "0"))
    else:
        print("-1")
    t = t-1

I don’t know why it was giving TLE although you have also used nested loops and hence O(n^2)… please help me?

https://www.codechef.com/viewsolution/16001364
Can you help me debugging my code please?

I’m getting WA in the second subtask in BUGCAL… Why?

https://www.codechef.com/viewsolution/15984308

My solution is in O(number of digits). I don’t know why it is giving TLE. This is my solution.
It is in Python. My logic is I calculate the number if I remove one digit, and check if it is divisible by 6 and greater than previously held value and replace it. Then append zeroes according to input if the first digit is removed.

e.g:- 3268398 is input,
num will hold the values (268398, 368398, 328398, 326398, 326898, 326838, 326839) in each iteration respectively.
Will check if it is divisible by 6 and greater than previously divisible value.

Thanks in advance.

I don’t know why i am getting RE(NZEC)?
this is my solution CodeChef: Practical coding for everyone

My code gives wrong ans.Any test case where it may fail?
link:CodeChef: Practical coding for everyone

for the second question ,every test case i checked is satisfied still i am getting a wrong answer please help me out pointing out just 1 test case that this code cannot run ??

https://www.codechef.com/viewsolution/15992968

@taran_1407 can you give some testcases for 2nd question.

https://www.codechef.com/viewsolution/15988759

What is wrong in this code for BUGCAL? PLease help. Everything handled!

@shivam2296 When you are swapping a&b then you should also swap the length also.

Taran, Can you help me debug my code? It seems like I’m missing some corner cases.

Edit: I’m sorry. The link was wrong. This is link to solution. CodeChef: Practical coding for everyone