Given an array **A**[] of **N** positive integers which can contain integers from **1** **to N** where elements can be repeated or can be absent from the array. Your task is to count frequency of all elements from **1 to N**.

**Note:** Expected time complexity is O(n) with O(1) extra space.

**Input: **

First line of input contains an integer **T** denoting the number of test cases. For each test case, first line contains an integer **N** denoting the size of array. The second line contains **N** space-separated integers **A _{1}, A_{2}, ..., A_{N}** denoting the elements of the array.

**Output:**

For each test case, output **N** space-separated integers denoting the frequency of each element from 1 to N.

**Constraints:**

1 ≤ T ≤ 100

1 ≤ N ≤ 10^{6 }

1 <= A[i] <= 10^{6}

**Example: **

**Input:**

2

5

2 3 2 3 5

4

3 3 3 3

**Output:**

0 2 2 0 1

0 0 4 0

**Explanation:
Testcase 1:** Counting frequencies of each array elements, we have:

Author: shef5

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

bruceewayne | 175 |

manvirag982 | 158 |

Core_Ka_Bachha | 137 |

yash_sharan | 136 |

rajupraaa1234 | 133 |

mr_kksparrow | 433 |

manvirag982 | 374 |

rajupraaa1234 | 268 |

Exception_404 | 254 |

PranathiBhuvanagiri | 242 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.