Open In App

Contest Experience : Leetcode Weekly Contest #375

Last Updated : 05 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

About the Contest:

Leetcode weekly contests are held virtually every weekend on their platform. These contests are helpful for programmers to test their coding skills by competing with coders worldwide. The plagiarism detector and community support on leetcode play an important role in ensuring fairness in the contest. Rankings were based on the following:

  • Maximum points
  • Minimum time to solve
  • The penalty for 1 wrong submission was 5 mins.

Prizes/Offers:

Leetcode always gives amazing goodies to rank holders:

  • Backpack for rank 1 to 3
  • Water Bottle for rank 4 to 10
  • Big O Notebook for rank 11 to 16

Link of the Contest: https://leetcode.com/contest/weekly-contest-375/

The duration of the contest was just 90 min and has ended but you can try the questions through this link. Your submissions won’t be considered for ratings.

Overview of all questions:

Problem Name

Difficulty

Total Points

Approx. time is taken by me

Number of Submissions

Count Tested Devices After Test Operations

Easy

3/3

18 min

1

Double Modular Exponentiation

Medium

4/4

20 min

1

Count Subarrays Where Max Element Appears at Least K Times

Medium

5/5

25 min

1

Count the Number of Good Partitions

Hard

0/6

Problem 1: Count Tested Devices After Test Operations

The contest first problem always has maximum submissions as it is easy level. It could be solved easily if you know basix arithemtic operations on array.

Approach: I declared two variables one for storing count of tested devices and other for comparing the current percentage of array. The constraints are satisfied by this brute force approach of Time and space complexity O(n). This question worked fine without optimization.

Problem 2: Double Modular Exponentiation

Approach: This was a medium level question but seemed to be easy at first glance because it just has a condition to be compared wit the target. My first approach of solving it was Math.pow() function of java and type casting with long datatype resulted WA. Later I applied brute force for solving the exponents using for loop, this approach worked fine and passed all test cases.

Problem 3: Count Subarrays Where Max Element Appears at Least K Times

This question reminded me of this problem from gfg no. of subarrays with maximum values in given range . The contest problem is variation of this.

Approach: The approach is to first find greatest number from array. I used 2 pointer to check if k occurence of maximum number occured and increment the count of subarray. This way code works fine with O(n) time complexity.

Problem 4: Count the Number of Good Partitions

Approach: I was not able to clear test cases with my approach so I didnt submit it. The issue faced was because the output variables needs modulus with 1e9+7. I now looked for a solution in which two pointers are used to iterate over the array, one starts from the beginning, and other to the last index of the current value. The counter is increented when to pointers match.

Conclusion:

In the end, I got a total 12/18 points and secured a rank of 2347 out of 16102 participants. I will try my best to solve all the question in the upcoming weekly contest.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads