Open In App

LeetCode: Weekly Contest #333

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

About the Contest:

This contest was organized by Leetcode on 19th Feb 2023, it consisted of 4 questions, and the time given to solve them was 1 hour 30 minutes.

Winning Prizes:

Rank

Prize

1st

Apple HomePod mini

2nd

Logitech G903 LIGHTSPEED Gaming Mouse

3rd-5th

LeetCode Backpack

6th-10th

LeetCode water bottle

11th-20th

LeetCode Big O Notebook

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

Overview of the questions asked:

Problem Name

Difficulty Level

Reward points for that question

Topics Related

Approx time taken to solve by me

Number of submissions made

Merge Two 2D Arrays by Summing Values

Easy

3

Array, Hashtable, Two-pointers

7 minutes

1

Minimum Operations to Reduce an Integer to 0

Medium

4

Dynamic Programming, Greedy, Bit manipulation

13 minutes

1

Count the Number of Square-Free Subsets

Medium

5

Array, Math, Dynamic Programming

21 minutes

3(2 WA)

Find the String with LCP

Hard

6

Array, String, DP,greedy

28-35 minutes

2 (1 TLE)

Question Discussion:

Problem 1: Merge Two 2D Arrays by Summing Values

My Experience and approach: The question was pretty simple, as two 2D arrays were given where the first element of array represented the id and the second element represented the value associated with that id. The task was to return a 2D array in which first element will be the unique id that is present in either of the two arrays or both the arrays and second element will be the sum of val associated with that id in the two array.

I solved this question using a hash map in which i made single hash map, and iterated in both the arrays and kept the sum of val associated with the same id and finally returned the elements of map.

Problem 2: Minimum Operations to Reduce an Integer to 0

My Experience and approach: The question asked to reduce n to 0 in minimum number of operations given that the operations to be performed on n is either add or subtract 2i from n. My initial thought was to bring the number to nearest power of 2 and after that the task is almost done. I coded it out in approximately 12-13 minutes.

Problem 3: Count the Number of Square-Free Subsets

My Experience and approach: This question I personally observed that it was of higher complexity and more inclined towards hard. The question asked to find the number of non-empty subsets in which product of its elements are not divisible by any square number other than 1. Tried to apply simple recursion but the approach failed for few testcases. Took a lot of time to come up with a bitmasking solution and finally solution was AC.

Problem 4: Find the String with LCP

My Experience and approach: It was a typical hard Dynamic programming question where the question demanded the deep understanding of DP on grids. Initially i applied the greedy approach but for one of my own generated testcase it was failing. After rectifying the code got Time Limit Exceeded error for my code. Later I optimized my code and applied dynamic programming to solve the problem.

Conclusion:

As far as my opinion is concerned, the contest was inclined towards the hard side of the spectrum. As the third question took a lot of brainstorming before figuring out the solution and of course fourth question as usual was hard. It took me around 1 hour and 16 minutes to complete the contest.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads