I was coding in some sort of university conquest and noticed something, when I declare a map in a loop such as down below:
for (int i = 0; i < n; i++) { map<int, bool> hashMap; //... } it takes more time than:
map<int, bool> hashMap; for (int i = 0; i < n; i++) { hashMap.clear(); //... } so I was wondering why does declaring an object in a loop has more time complexity than just re-initializing it?
https://stackoverflow.com/questions/65545218/performance-of-declaring-objects January 03, 2021 at 07:33AM
没有评论:
发表评论