Don't worry guys ! I found out the O (n) algorithm.