Given an array of integer arr (may include duplicate numbers and negative integers)
Then given a legal query string query specifying some ranges (see example)
Return all numbers in arr satisfying query query in ascending order.
Query Rules:
Single number: 2 means only 2, as [2, 2]
Range: -1~3 means query range from -1 to 3, as [-1, 3), which inclusive on left and exclusive on right // see Example 2
^ means and, v means or, and would be operate in prior to or
Query string may be a very long string, and could contains overlapping ranges.
All numbers in in query are within range of int
Example 1:
arr = [-1, 0, 0, 2]
query = "-1~3" // query range from -1 to 3
result = [-1, 0, 0, 2]
Example 2:
arr = [-1, 0, 0, 2]
query = "-1~0v2" // query range from -1 to 0 or 2
result = [-1, 2]
Example 3:
arr = [2, 0, -1, 0]
query = "0~2^-1~1v2"
result = [0, 0, 2]
Given an array of integer
arr
(may include duplicate numbers and negative integers) Then given a legal query stringquery
specifying some ranges (see example) Return all numbers inarr
satisfying queryquery
in ascending order.Query Rules:
2
means only2
, as[2, 2]
-1~3
means query range from-1
to3
, as[-1, 3)
, which inclusive on left and exclusive on right // see Example 2^
meansand
,v
meansor
,and
would be operate in prior toor
query
are within range ofint