Trapping Rain Water

Given an elevation map where the width of each bar is 1, return the total amount of rainwater that can be trapped.

Examples
Input: [0,1,0,2,1,0,1,3,2,1,2,1]
Output: 6
Hints

Trapping Rain Water

Given an elevation map where the width of each bar is 1, return the total amount of rainwater that can be trapped.