1 / 10
Dec 2014

Problem Link: http://www.spoj.com/problems/WTK/6
Here are two of my submissions to this problem.
Code 1:

Removed

Code 2:

Removed

Both the codes are same except the function calling, but to my surprise, one got AC with a time around 1.7s while the other around 0.9s!
I don't understand what made so much difference.
Can anyone tell me why?
Thanks in advance.

Edit:
Same thing for the other Josephus problem Musical Chairs.
Problem Link: http://www.spoj.com/problems/ANARC08H/3
Calling a function is reducing time by two!

  • created

    Dec '14
  • last reply

    Mar '15
  • 9

    replies

  • 850

    views

  • 4

    users

  • 8

    links

Please [color=#FF0000]REMOVE YOUR CODE.[/color]
Unfortunately there are some users that like to post other's working code without solving the problem themselves.
Posting AC code in the forum makes it even easier for them.

Sorry for posting AC code.
Unfortunately that link doesn't answer my query. confused

@leppy, thank you for your reply.
Of the two codes I posted earlier, the one which involves the function calling was faster not the one without function calling.
Edit: I should've known! Use of local variables was the reason of that speed.

3 months later

From this same topic:

It's an assumption. I have seen many of these posts over the past few years that I have been on this forum.

Wow, I'm humbled. I'm not sure that I want that much attention smile I'll think about it.