Really good solution! I struggled a bit with these one, I couldnt get all the tests to pass. Your solution was pretty elegant, but I wonder how good is the performance of that algorithm, are there any alternatives?
@wrttech422 Жыл бұрын
Since the function's behavior and execution time do not depend on the size of the input or involve any loops or recursive calls, the time complexity can be considered constant O(1). It will always execute in the same amount of time, regardless of the input. As for alternatives, there are probably a lot, but im pretty sure that this is the least amount of code possible. Another popular way would be an if else statement, but it would have a few more lines of code. Time complexity would be the same though.
@juanrolon1729 Жыл бұрын
@@wrttech422 do you believe this solution would scale well if containerized like in docker or something or it cant handle concurrency?
@wrttech422 Жыл бұрын
That really depends on the infrastructure and architecture of the system. This function runs in O(1) which is the fastest possible time complexity. You can still run into issues, such as race conditions, with the most efficient function in the world.