Driver Code
if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 7 NEW_LINE ar = [ 1 , 2 , 1 , 3 , 1 , 2 , 1 ] NEW_LINE seg = [ 0 ] * 4 * n NEW_LINE build ( 0 , n - 1 , 1 , ar , seg ) NEW_LINE q = 5 NEW_LINE queries = [ [ 2 , 1 , 4 ] , [ 1 , 4 , 2 ] , [ 1 , 5 , 2 ] , [ 2 , 4 , 6 ] , [ 2 , 1 , 7 ] ] NEW_LINE getDistinctCount ( queries , ar , seg , n ) NEW_LINE DEDENT