you give 0indexe array nums1 nums2 length n permutation 0 1 n 1A good triplet set 3 distinct value present increase order position nums1 nums2 in word consider pos1v index value v nums1 pos2v index value v nums2 good triplet set x y z 0 x y z n 1 pos1x pos1y pos1z pos2x pos2y pos2zreturn total number good triplet Example 1input nums1 2013 nums2 0123output 1explanation there 4 triplet xyz pos1x pos1y pos1z they 201 203 213 013 out triplet triplet 013 satisfie pos2x pos2y pos2z hence 1 good tripletExample 2input nums1 40132 nums2 41023output 4explanation the 4 good triplet 403 402 413 412 Constraintsn nums1length nums2length3 n 1050 nums1i nums2i n 1nums1 nums2 permutation 0 1 n 1