Open In App

Contest Experiences | Geeksforgeeks GFG Weekly Coding Contest – 105

Last Updated : 26 Sep, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

About the Contest: Geeksforgeeks GFG Weekly Coding Contest – 105

This was a contest organized on the Geeks for Geeks platform on June 4th, 2023 and it consisted of 3 questions that were to be solved in a time frame of 90 minutes from 7:00 PM to 8:30 PM.

Prizes/Offers:

There was a 2 Geeksbits prize for anyone who scored during the contest along with an 8 Geeksbits bonus prize for the top 8 rankers in the contest.

Note: Geeksbits are the currency used in the Geeks for Geeks platform which can be redeemed to buy swags or different course vouchers. Visit here to learn more about the rewards page.

Link of the contest:

Geeksforgeeks GFG Weekly Coding Contest – 105

Overview of the questions asked :

Problem name

Difficulty Level

Time to Solve

Pre-requisites

Number of submission made by me

Minimum Thorns

Easy

7-8 minutes

2d matrix

1

Running Instructions

Easy-Medium

18-20 minutes

Dynamic programming

3 (2 WA)

Path Sum Queries

Hard

Was not able to solve

Dynamic programming

Experience:

Problem 1: Minimum Thorns

  • Basically, we have to find the minimum number of thorns required to be placed in order to block accessibility from one position of the 2d array to the other.
  • So, here if the two positions are just adjacent(not diagonally) to each other then they will always be reachable from one another, therefore the answer in this case will be -1.
  • But if they are not adjacent then we have to place the minimum number of thorns to block which can be found by taking the minimum of number of valid adjacent positions for both geek and geekina.
  • The above solution works fine because if we block all the adjacent positions of either geek or geekina then they will surely become unreachable from all other positions of the array.

Problem 2: Running Instructions

  • In this problem we have to find the sequence of instructions(clockwise or anticlockwise) to be performed on a circular track to end up at the starting position of Geek.
  • This problem involved knowledge about dynamic programming concepts where we have to assign a clockwise(+ve) or anticlockwise(-ve) direction to each instruction each at a time and explore all the possible solutions.
  • If any of the solution returns that it is possible to end up at the starting position then we have the answer as YES otherwise the answer is NO.
  • The recursive DP function takes the current index of the instruction to be performed and the current distance(curr) of the Geek from its starting position and performs operation as, either (curr + k[index]) or (curr – k[index]).
  • I got two Wrong answers during submission due to my mistake of trying to solve it greedily, but here we have to explore all possible outcomes and choose the required one.

Problem 3: Path Sum Queries

  • I was not able to solve this problem because I think the question was a bit unclear but here is what I tried to implement.
  • In this problem, we have to check for every query if there is a path from the top-left cell to the bottom-right cell in a grid so that if we sum up all the numbers visited in the path then it is equal to the query given.
  • For each query we have to first check if the value in query is divisible by k, if it is then we can have an answer but if its not then the answer is not possible for sure.
  • Since for any path we can define its sum as,

Sum of path = x*k + y*(-k) = k*(x-y), where x and y are integers >= 0.

So, we can see that sum is always a multiple of k. But even if the sum is a multiple of k then also we are not sure of its existence. Below is the link where you can watch the Post contest analysis to understand more about the concept of this problem.

Conclusion:

  • Overall, I would rate this contest on a tougher side as there were two questions that involved dynamic programming and the last question was the one which made me to struggle the most.
  • I was able to solve only first two questions within the time frame because the third question was bit unclear and I have to watch the Post contest analysis to understand it.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads