design datum structure find frequency give value give subarrayThe frequency value subarray number occurrence value subarrayimplement RangeFreqQuery classRangeFreqQueryint arr Constructs instance class give 0indexed integer array arrint queryint leave int right int value return frequency value subarray arrleftrighta subarray contiguous sequence element array arrleftright denote subarray contain element num index leave right inclusive Example 1inputrangefreqquery query query12 33 4 56 22 2 34 33 22 12 34 56 1 2 4 0 11 33outputnull 1 2explanationrangefreqquery rangefreqquery new RangeFreqQuery12 33 4 56 22 2 34 33 22 12 34 56rangefreqqueryquery1 2 4 return 1 the value 4 occur 1 time subarray 33 4rangefreqqueryquery0 11 33 return 2 the value 33 occur 2 time array Constraints1 arrlength 1051 arri value 1040 leave right arrlengthat 105 call query