two WA solutoin, need to be fixed
a linear time solution from geeksforgeeks