URI Oj Problem -- 1221 & 1170

Problem : 1221

Problem Link 

Solution :



Problem : 1170

Problem Link