update solution for finding next bigger and smaller number