I have an array that I need to loop through each distinct element and get corresponding details. Provided array result obtain finalResult or
result
finalResult