October LunchTime UNofficial Editorials (First two problems) Revised

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

Hey taran I am getting wa for the 2nd subtask in the problem BUGCAL. Any testcase where I might fail. Hereā€™s the link to my solution - link text

Hey @taran_1407, did you solve the third problem i.e. Optimal Subset?
I have a conventional O(n^2) DP approach and optimizing it seems way too difficult to me and I canā€™t even think of any other way to approach that problem too.
Any suggestions on that?

Loving your explanations dude.

well done C.A :stuck_out_tongue: as your institute suggests

code , can you please help me out why it is giving wrong answer.

@taran_1407
I am getting run-time error. I tried too much to find where i am getting this but failed.
please help me.
this is my codeā€“>
https://www.codechef.com/viewsolution/15994545
thank you

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 k-1 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 k-1 and maxnum to it. LINK:-My Solution

Taran, sorry for posting that link which didnā€™t work. I updated it. Can you help me?

In problem maximum number in my code I am not able to figure out mistake.
It gives wrong answer on submission.

Can anyone help me debugging it.
Link to my code is

Here.

Please help :slight_smile:

i dont know why my code is getting wrong anser.
please help me;
link is CodeChef: Practical coding for everyone

i dont know why my code is getting wrong answer, please help; link CodeChef: Practical coding for everyone

simply just check when sum of the digit >= 10 take mod of the ans and store it in an array during calculation in O(n) time then print the same

Hey can anyone plz tell me whatā€™s wrong with this code?
CodeChef: Practical coding for everyone

Mate, Your solution is O(n^2) because Substring function itself take O(N) time because it has to transverse whole string. Further, using Integer.parseInt this many times, you can simply store a number in array, ith element of array being ith digit of number (from left to right or right to left, as you feel comfortable with. :slight_smile: ).

2 Likes

Mate, i replied on your thread too. Iā€™m still working with your solution only. :slight_smile:

sorry bro didnā€™t see then. thanks :slight_smile:

Try Following test case.

1

55 54

Correct answer 9

Your answer 09

No problem mate.