For many people being confused by the answer being either 1 or 2, here's an explanation that might help.
4 instances of R given.
3 Processes given.
Let each process take 1 resource. 1 R left. Clearly, K can be 1 since deadlock wont happen.
Now lets take 2.
In the worst case, every process will take 1 resource each with one R left out.
Assume P1 takes the remaining 1 R again and P2 requests for R. P2 will wait till P1 finishes. Therefore no deadlock. K=2.
Now lets try 3
Worst case again, each process takes 1 resource with 1 R left out. Say P1 requests for 2 more - it will lead to a deadlock since only 1 is available and 1 more is needed. Deadlock means program is literally 'dead' and 'locked' with no progress at all.
Therefore, K=2