Why such vast execution-time difference in the two solutions?
Difference between en6 and en7, changed 0 character(s)
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.↵



![ ](/predownloaded/82/8d/828d565a6057cdbd9acc55769d996489cdc4e877.png)↵


My First solution which took more than 2000ms (https://atcoder.jp/contests/dp/submissions/24396061)↵
![ ](/predownloaded/53/05/530562676dbef053e0e35327a8ac92d92fc08b4c.png)↵


My Second solution which took less than 200ms (used global variables) (https://atcoder.jp/contests/dp/submissions/24396078)↵
![ ](/predownloaded/dc/6f/dc6f42633b241fe768e3d77a1e24a4229482e8c8.png)↵


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

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en7 English Kmare 2021-07-19 22:57:23 0 (published)
en6 English Kmare 2021-07-19 22:56:59 24 Tiny change: 'an 200ms (https://' -> 'an 200ms (used global variables) (https://'
en5 English Kmare 2021-07-19 22:56:09 6 Tiny change: 'on time.\n![ ](/pr' -> 'on time.\n\n\n\n![ ](/pr'
en4 English Kmare 2021-07-19 22:55:52 12
en3 English Kmare 2021-07-19 22:55:14 270
en2 English Kmare 2021-07-19 22:53:14 95
en1 English Kmare 2021-07-19 22:52:22 689 Initial revision (saved to drafts)