This probably varies per company. If you're working on a problem that others have done, you can expect the company to have little interest in your specific solution. They've seen very many versions of the same work.
If the task is more about working for a trial day or week, you'll be working in the company's codebase. You can expect to sign an NDA and to give up rights to your work. The company should pay you for this work.
What are the common pitfalls? Any logistics to smooth the process? How often do you refresh the problem?