Forwarded from Hanan S.
'''
You are given a 2D integer array of student data students, where students[i] = [student_id, bench_id] represents that student student_id is sitting on the bench bench_id.
Return the maximum number of unique students sitting on any single bench. If no students are present, return 0.
Note: A student can appear multiple times on the same bench in the input, but they should be counted only once per bench.
Example 1:
Input: students = [[1,2],[2,2],[3,3],[1,3],[2,3]]
Output: 3
Explanation:
Bench 2 has two unique students: [1, 2].
Bench 3 has three unique students: [1, 2, 3].
The maximum number of unique students on a single bench is 3.
Example 2:
Input: students = [[1,1],[2,1],[3,1],[4,2],[5,2]]
Output: 3
Explanation:
Bench 1 has three unique students: [1, 2, 3].
Bench 2 has two unique students: [4, 5].
The maximum number of unique students on a single bench is 3.
Example 3:
Input: students = [[1,1],[1,1]]
Output: 1
Explanation:
The maximum number of unique students on a single bench is 1.
Example 4:
Input: students = []
Output: 0
Explanation:
Since no students are present, the output is 0.
Constraints:
0 <= students.length <= 100
students[i] = [student_id, bench_id]
1 <= student_id <= 100
1 <= bench_id <= 100
'''
# max = max(
# iterate 1-n / len array O(n)
# iterate over each rows O(n)
# compare prev row prev index
# if greater update max value
# return max value
# create hash map
# iterate over 0-n/ len arrar
# bech id as key , count
# iterate over the hash map
# return the max value
def counter(arr):
studentCounter = {} # O(n)
for i in range(len(arr)): # O(n)
studentCounter[arr[i][1]] = studentCounter.get(arr[i][1],set())
studentCounter[arr[i][1]].add(arr[i][0])
max_students = 0
for students in studentCounter.values(): # O(m)
max_students = max(max_students, len(students))
return max_students
# time complexity -- O(n+m) = O(n)
# space complexity -- O(n)
students = [[1,2]]
print(counter(students))
You are given a 2D integer array of student data students, where students[i] = [student_id, bench_id] represents that student student_id is sitting on the bench bench_id.
Return the maximum number of unique students sitting on any single bench. If no students are present, return 0.
Note: A student can appear multiple times on the same bench in the input, but they should be counted only once per bench.
Example 1:
Input: students = [[1,2],[2,2],[3,3],[1,3],[2,3]]
Output: 3
Explanation:
Bench 2 has two unique students: [1, 2].
Bench 3 has three unique students: [1, 2, 3].
The maximum number of unique students on a single bench is 3.
Example 2:
Input: students = [[1,1],[2,1],[3,1],[4,2],[5,2]]
Output: 3
Explanation:
Bench 1 has three unique students: [1, 2, 3].
Bench 2 has two unique students: [4, 5].
The maximum number of unique students on a single bench is 3.
Example 3:
Input: students = [[1,1],[1,1]]
Output: 1
Explanation:
The maximum number of unique students on a single bench is 1.
Example 4:
Input: students = []
Output: 0
Explanation:
Since no students are present, the output is 0.
Constraints:
0 <= students.length <= 100
students[i] = [student_id, bench_id]
1 <= student_id <= 100
1 <= bench_id <= 100
'''
# max = max(
# iterate 1-n / len array O(n)
# iterate over each rows O(n)
# compare prev row prev index
# if greater update max value
# return max value
# create hash map
# iterate over 0-n/ len arrar
# bech id as key , count
# iterate over the hash map
# return the max value
def counter(arr):
studentCounter = {} # O(n)
for i in range(len(arr)): # O(n)
studentCounter[arr[i][1]] = studentCounter.get(arr[i][1],set())
studentCounter[arr[i][1]].add(arr[i][0])
max_students = 0
for students in studentCounter.values(): # O(m)
max_students = max(max_students, len(students))
return max_students
# time complexity -- O(n+m) = O(n)
# space complexity -- O(n)
students = [[1,2]]
print(counter(students))
Channel Summary for 2025 🎉
Views
• 472 Total Posts
• 501 Average Views
• 236,817 Total Views
Top Post
• 2,058 Views
• https://news.1rj.ru/str/leetcodeQ/1131
Activity
• 7 PM is when you were most active
• Wednesday is your most active day
• February is your most active month
@channel_unwrapped_bot #channel_unwrapped
Views
• 472 Total Posts
• 501 Average Views
• 236,817 Total Views
Top Post
• 2,058 Views
• https://news.1rj.ru/str/leetcodeQ/1131
Activity
• 7 PM is when you were most active
• Wednesday is your most active day
• February is your most active month
@channel_unwrapped_bot #channel_unwrapped
⚡5
I am building a Taxi Mela mobile app with my team for our final year project.
You can find taxi stations.
You can search using destinations, see the route, and the taxi fare.
Would you use this app? How would you rate its importance? Please give me any recommendations in the comments or inbox.
You can find taxi stations.
You can search using destinations, see the route, and the taxi fare.
Would you use this app? How would you rate its importance? Please give me any recommendations in the comments or inbox.
⚡6
from 10 rate the app usefullness for u
Anonymous Poll
48%
9-10
16%
7-8
13%
4-6
6%
<3
17%
see the result
👍5
This is what I want to hear -- congratulations for those who passed, and if u didn't pass don't worry u will pass the next round in two months
❤17😭3💔1
Forwarded from Lord of the Beans
You don't know me and I don't know you, but the questions you sent helped me be prepared and I finally got in so I just wanted to give my Thanks
❤14
Forwarded from Hizkeal
Thanks Dani for all your help, the channel and the resources you shared me were tremendously helpful.
❤7
Forwarded from Amanuel ❼
Thank you, Dani, for your resources and all the information.
I got accepted G7 (A2SV)
I got accepted G7 (A2SV)
❤4