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?
↵
↵
↵
![ ](/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?