According to a solution code of a problem from stackoverflow.