Why such vast execution-time difference in the two solutions?

Правка en6, от Kmare, 2021-07-19 22:56:59

I was solving "Digit sum" problem of Atcoder DP contest. I am just curious why my two solutions have such a vast difference in their execution time.

My First solution which took more than 2000ms (https://atcoder.jp/contests/dp/submissions/24396061)

My Second solution which took less than 200ms (used global variables) (https://atcoder.jp/contests/dp/submissions/24396078)

Just adding some more parameters to a function completely changed the time complexity, strange isn't it?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en7 Английский Kmare 2021-07-19 22:57:23 0 (published)
en6 Английский Kmare 2021-07-19 22:56:59 24 Tiny change: 'an 200ms (https://' -> 'an 200ms (used global variables) (https://'
en5 Английский Kmare 2021-07-19 22:56:09 6 Tiny change: 'on time.\n![ ](/pr' -> 'on time.\n\n\n\n![ ](/pr'
en4 Английский Kmare 2021-07-19 22:55:52 12
en3 Английский Kmare 2021-07-19 22:55:14 270
en2 Английский Kmare 2021-07-19 22:53:14 95
en1 Английский Kmare 2021-07-19 22:52:22 689 Initial revision (saved to drafts)