Link : https://www.codechef.com/MAY17/problems/UNICOURS/
MY Sol : http://ideone.com/BGnFLx
Although i have solved this problem but just want to know why my hashing approach is not working???
Link : https://www.codechef.com/MAY17/problems/UNICOURS/
MY Sol : http://ideone.com/BGnFLx
Although i have solved this problem but just want to know why my hashing approach is not working???
hey , i think you are considering A[i] as course (id), but it’s number of courses that are prerequisite courses for i-th course.
example : if A[i] = 5
by hashing it should be (hash[0 to i-1]++) not hash[A[i]]++
It may give TLE so there is easy approach : here
It fails in this testcase:
1
4
0 1 1 3
Your code outputs 2. But answer is 1.
Ok Got my mistake!!!
thanks!!
Ya got it .Thanks btw.
I just came up with a easy solution than hashing…
Here is my solution:
it’s a simple finding maximum element of an array problem i guess