SoftwareOne interview question

2 medium level exercises on leetcode