Should such CS coursework be subject to plagiarism?
This is basically a request for opinions because there isn't a general answer to the definition of plagarism in coding. Borrowing code is a huge part of learning how to code!

That said here are my guidelines for myself:

make choices you're comfortable with. 


If it feels wrong it probably is. You should be willing to openly stand by every decision and every google search. 

add comments with sources throughout your code. 


This will make things way easier just from a coding perspective and if you're accused of plagarism, makes it easier to argue that you were not intending to do so. 

In particular, I link to stack exchange answers that were helpful, especially to questions I asked. 

you could even put a link to this thread in your submission code somewhere so that you can demonstrate that you clearly thought about academic honesty. 

Intent matters a lot in plagiarism at a grad or post grad level. It's when things are getting published that it becomes much more objective.