What is the space and time complexity of the following code?

Time Complexity:

The first loop runs from i = 0 to i = n-1, with n repetitions.
The second loop runs from j = 0 to j = n-1, with n repetitions.
Both loops are linear, with n iterations each. The code’s temporal complexity is O(n+n)=O(2n)=O(n), where n is the input size.

Space Complexity:

The code sample makes use of two integer variables, i and j, which require constant space. As a result, their space utilization is independent of the input size n.
The loops themselves don’t introduce any new data structures or allocate dynamic memory dependent on n.
The code snippet has a space complexity of 𝑂(1), or constant space, as it utilizes a fixed amount of space regardless of input.