The solution for both :

A = [5, 5, 5, 100, 100] B = 105 Expected Answer = 3

A = [5, 5, 5, 90, 100] B = 105 Expected Answer = 3

Should not the answers be different for both of them ?

The solution for both :

A = [5, 5, 5, 100, 100] B = 105 Expected Answer = 3

A = [5, 5, 5, 90, 100] B = 105 Expected Answer = 3

Should not the answers be different for both of them ?

Problem statement says " Sorted Distinct Integers". Your test case does not satisfy this condition.