The lens hood fixation is a combination of a short thread + a bayonnet mount to lock the hood in position. I usually install and remove the hood with the lens on the camera. When I have the camera with the strap around my neck, you will see a white dot just beneath the Pentax word (between N and T). The white dot must be at 12 o'clock when locked, and about 2 o'clock when unlocked.
blackcloudbrew is correct for the rotation direction. Again, if I have the camera with the strap around my neck, and I look at the lens mounted on my camera, I un-lock by turning the hood to the right. (Remember to use the white dot if you can. It really helps.)
Generally it is easier to unlokc the lens. Locking the hood requires a little more fiddling until the hood is on the right thread.
Hope that the comment will help.