Hi!
I've found this strange thing(maybe not that strange who already knows it). Can anyone explain why this takes less time and memory complexity in C++14 and C++17 compilers than in the C++20 compiler? I've attached the time and memory complexity of this problem below.
It's not different time/memory complexity. That'd usually be something like 10000% difference, not 50%. It's different time/memory, which is normal because different compilers produce different code which consumes different resources. If it was always the same, there'd be no point in having those different compilers, no?
I understand, what I don't is the memory complexity of 120836KB & 187964KB in 17 and 20 respectively.
14/17 are 32 bit, 20 is 64 bit. Any pointers (eg return addresses on stack) are therefore twice as big. On top of that the stack usage for a function is generally higher in x64 due to different alignment / calling conventions.
You can't have memory complexity of 187964KB or 2GB or whatever... Memory complexity can be $$$O(n^2)$$$, $$$O(n)$$$, $$$O(1)$$$, etc.