int getWidth(int index) {
        int count = 1;
        for (int i = index - 1; i > -1; i--) {
            if (height[i] >= height[index])
                count++;
            else
                break;
        }

        for (int i = index + 1; i < height.length; i++) {
            if (height[i] >= height[index])
                count++;
            else
                break;
        }
        return count;
    }