Demand
Query whether 2 numbers are within two number intervals
Data
There are two numbers A = 12
,B = 15
Has a set of arrays
var Arr = [[11,12],[12,15],[15,17]];
Algorithm
A
and B
whether the Arr[0]
two-digit range of the array
Error Demo
if(A > Arr[0][0] && A < Arr[0][1] || B > Arr[0][0] && B < Arr[0][1]){ return false;}return true;
Help
Ask JS, php,java,c#, Golang, algorithm realization, hope each big God can write the highest performance algorithm!!!
Where is the great God?
Reply content:
Demand
Query whether 2 numbers are within two number intervals
Data
There are two numbers A = 12
,B = 15
Has a set of arrays
var Arr = [[11,12],[12,15],[15,17]];
Algorithm
A
and B
whether the Arr[0]
two-digit range of the array
Error Demo
if(A > Arr[0][0] && A < Arr[0][1] || B > Arr[0][0] && B < Arr[0][1]){ return false;}return true;
Help
Ask JS, php,java,c#, Golang, algorithm realization, hope each big God can write the highest performance algorithm!!!
Where is the great God?
((A >= Arr[0][0] && A <= Arr[0][1]) && (B >= Arr[0][0] && B <= Arr[0][1]))
if A>B: return self.compare(B,A)return A>Arr[0][0] and B