Mastercard Interview Question

stock span problem, dynamic programming