Practice
Resources
Contests
Online IDE
New
Free Mock
Events New Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
logo
Events
Attend free live masterclass hosted by top tech professionals
New
Scaler
Explore Offerings by SCALER

Row-wise unique

Problem Description

You are collaborating with a tech team for an EdTech organisation. It is currently working on a special feature for Instructors' dashboard which will help the instructor in knowing about the engagement of his students for the class Assignments in the form of number of times a particular student contacts his/her TA (Teaching Assistant) on a particular day.

So whenever a student with an id i contacts his TA on jth day, i is stored in the jth row of a matrix for that particular batch. As you can see this data storage can become very large as a student can contact his/her TA multiple times in a day and there can be a significant number of batches also. The team is facing this storage issue.

Here you are asked to create a prototype program which is just for a batch of 10 students and for m days for visualising the solution on a large scale.

For the program the input matrix consists of elements with values 1-10 (students' ids) of dimension mxn, the output is expected to be a 2d list of dimension m*10 (m is the number of days and 10 columns because students number is only 10 here), but this time the elements will be the count of the that element in that particular row i.e. the number of times a student contacts on ith day.

Input Format:
number of test cases
for each test case (number of rows for matrix)
for each row in matrix space separated integers in a new line

Output Format:
The 2dlist is simply printed

Sample input:
1
5
1 1 2 5 7 6 7 7 6 3
8 5 4 7 5 2 6 10 1 7
4 3 10 4 4 4 3 1 4 3
1 4 1 1 8 4 9 8 5 5
1 1 4 4 2 10 5 6 8 1

Sample output:
[[2, 1, 1, 0, 1, 2, 3, 0, 0, 0], [1, 1, 0, 1, 2, 1, 2, 1, 0, 1], [1, 0, 3, 5, 0, 0, 0, 0, 0, 1], [3, 0, 0, 2, 2, 0, 0, 2, 1, 0], [3, 1, 0, 2, 1, 1, 0, 1, 0, 1]]
where you can see that in the output[0][0], the element is 1 which depicts that 1 occurs only single time in the 1st row in the input matrix.

Note:
  • Here you don't have to write the code for taking input its already included in the code suffix which you would be able to see right below the function editor.
  • The output is a simple 2d matrix(2d list) printed simply without any formatting.



Start solving Row-wise unique on Interview Code Editor
Hints
  • Hints are not available for this problem

Discussion


Loading...
Click here to start solving coding interview questions
Free Mock Assessment
Fill up the details for personalised experience.
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
Graduation Year *
Graduation Year *
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
*Enter the expected year of graduation if you're student
Current Employer
Company Name
College you graduated from
College/University Name
Job Title
Job Title
Engineering Leadership
Software Development Engineer (Backend)
Software Development Engineer (Frontend)
Software Development Engineer (Full Stack)
Data Scientist
Android Engineer
iOS Engineer
Devops Engineer
Support Engineer
Research Engineer
Engineering Intern
QA Engineer
Co-founder
SDET
Product Manager
Product Designer
Backend Architect
Program Manager
Release Engineer
Security Leadership
Database Administrator
Data Analyst
Data Engineer
Non Coder
Other
Please verify your phone number
Edit
Resend OTP
By clicking on Start Test, I agree to be contacted by Scaler in the future.
Already have an account? Log in
Free Mock Assessment
Instructions from Interviewbit
Start Test