Piping ls to cp in unix

How to copy the result of ls to directory

Actually this would be a generic implementation. But, as an illustration, if you want to pass the result of ls [list command] to copy, cp, command in unix you can do

ls /some/directory | xargs -i cp {} /new/copy/directory

Just piping the list to cp so that cp can you the listed values to copy.
As you can see this can be implemented to a lot more commands like mv, rm …

Say if you want to move the result of ls to new destination

ls /some/directory | xargs -i mv {} /new/copy/directory

How would you solve the following algorithms?

From billion numbers, find missing numbers with limited memory

Finding K complementary numbers from the given array