# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Well, I will not waste your time and go straight to the problem.

You are given an array **A** of numbers. And some queries. Each query consists of two ranges. You need to find out if those two ranges are similar or not. You are given a function to figure out if two ranges are same or not.

```
function IsSame(x1, y1, x2, y2)
Array1 = []
Array2 = []
For i = x1 to y1
Array1.push(A[i])
end For
For i = x2 to y2
Array2.push(A[i])
end For
NewArray1 = sort the elements inside Array1
NewArray2 = sort the elements inside Array2
return (NewArray1 equals NewArray2)
end function
```

The first line contains two integer N - number of elements in the array and Q - number of queries.
Next line contains **N** integers denoting the **i ^{th}** element of the array

Next there are Q queries with four integers which is described above.

- 1 ≤ N, Q ≤ 10
^{5} - 1 ≤ A[i] ≤ 10
^{5} - 1 ≤ x1, y1, x2, y2 ≤ N

For each query, use the function given above and if the function returns true value print “Yes” otherwise print “No” without quote .

Input | Output |
---|---|

6 3 1 2 3 1 2 3 1 3 4 6 2 4 3 5 1 2 2 3 | Yes Yes No |

48% Solution Ratio

sakibalaminEarliest,

sakibalaminFastest, 0.0s

Alamin_justLightest, 1.2 MB

subhashis_cseShortest, 559B

Login to submit