Calculation of Memory ?

How is the memory of a problem is calculated?Can anyone tell me about the space complexities, how is that calculated?

If you are familiar with time complexity, calculation of space complexity works in a similar manner, except that the resource being measured is different. The variables on which space complexity will depend on are the data types of the variables and the number of variables which are being allocated memory. For example, storing an integer array of ā€˜Nā€™ elements is said to take up O(N) space, as 4N bytes will be allocated for it, which is of the form (constantN).

The memory used by your program can vary, depending on the quantity of resources being used by your program at a given time, which includes stack memory, number and sizes of variables used, etc.