Here I am just putting python code.
if(X==0 and K==0):
elif(X<=0 or K<=0 or N<0):
Provided that all element of Arr are distinct,this conclude that all sub problems are non-overlapping(just took an small case, do it manually)
Please Evaluate Time Complexity in terms of N,K,X.
Thanks for reading this question...
Basically this problem is regarded as depth first search of a binary tree whose height is bounded by
max(N,K). So order of time complexity is bounded by
2^max(N,K). And then
Arr might reduce this time complexity. But it is unclear because it depend on the values of
X. (For example if Arr=[inf,...,inf], the time complexity will be