Implement a function named find_max_diff(arr, n=None) that calculates the maximum absolute difference between the nearest smaller elements to the left and right of each element in the input array.
Functionality Requirements:
If n is not provided, it should default to the length of arr.
If arr is empty, the function should return 0.
The function should utilize a stack to efficiently determine the nearest smaller elements on both sides for each element in the array.
The returned value should be the maximum of the absolute differences computed for each element in arr.
Input/Output Requirements:
Input:
arr (list of integers): An array of integers where the computation is to be made.
n (int, optional): The length of the array; if not provided, it will be determined from the array's length.
Output:
An integer representing the maximum absolute difference computed as specified.
Implementation:
The solution must be written in a file called /app/solution.py.