```
Hi All,
How to calculate time and space complexity of number.Below id the problem statement and also my solution
Problem Statement:
# Reverse a number using stack
Example :Input : 123 Output : 321
Code:
public class Solution {
public static void main(String[] args) {
int number = 39997;
System.out.println(reverse_number(number));
}
static Stack<Integer> st = new Stack<>();
static void push_digits(int number) {
while (number != 0) {
st.push(number % 10);
number = number / 10;
}
}
static int reverse_number(int number) {
push_digits(number);
int reverse = 0;
int i = 1;
while (!st.isEmpty()) {
reverse = reverse + (st.peek() * i);
st.pop();
i = i * 10;
}
return reverse;
}
}
```

Time Complexity : ?

Space Complexity: ?

Could anyone explain me how to calculate above mentioned terms.

Thanks