Array Operation, The Challenge Day and Magic Board

Problem Discussed Today: 
  1. Array Operation ( CodeChef )
  2. The Challenge Day ( CodeChef )
  3. Magic Board ( CodeChef )
Editorial

1. Array Operation
This is the simplest problem of which we have got by luck as the problem are selected randomly.

This problem just asks us to calculate number of distinct elements in the array starting from position m in 1 based array.

But for each operation, we cannot calculate as we will get TLE Error. So we need to do some preprocessing.

To implement this I have used a Freq[100001] array which will be >0 if we have encountered the number previously else 0. If it is zero then it is zero. And initializing a sum variable = 0 initially and started traversing array from the end and updated the same array in my solution.

if(freq[arr[i]]>0) {
     sum++;
     freq[arr[i]]++;
}
arr[i]=sum;

after that answer would be arr[i] for m=i;

Solution Link


2. The Challenge Day
A heavy problem that needs to be discussed in Slack. For your reference, there is an Editorial by CodeChef.




3. Magic Board
A heavy problem that needs to be discussed in Slack. For your reference, there is an Editorial by CodeChef.

I hope to discuss the last two problems with you and soon develop an easy editorial for all.

Thank You

Comments