SnapChat Tech Screen Feb 2024
Anonymous User
1037

Connect Pairs (from hacker rank)

Input : [Ba, _a, cb, dc]
output : _abcd

Input : [El, ll, lo, _h, he]
output : _hello

condition : the resultant string should begin with _

In this question, one had to connect the pairs. In this [Ba, _a, cb, dc] one example of pair is ba, _a, cb & dc.

Have to place pairs in a way such that second character in each pair is same as first character in next pair. Like :
[Ba, _a, cb, dc] to[ _a, ab, bc, cd]

Finally, remove all the redudant adjacent character : From [ _a, ab, bc, cd] to _abcd

Can anyone help paste a similar question on leetcode ? Unable to find one.

Comments (4)