The sum is a specific number. Is there any way to solve this problem in linear-time algorithm?