Contest Experiences | Leetcode bi-weekly contest #112
About the contest: Leetcode bi-weekly contest #112
This contest was organized by Leetcode on Sep 2, 2023, it consisted of 4 questions and the time given to solve them was 1 hour 30 minutes i.e. 90 mins
Link of the contest: Leetcode Biweekly Contest 112
Perks/Prizes/Offers:
RANK |
COINS |
---|---|
1st |
5000 |
2nd |
2500 |
3rd |
1000 |
4-50th |
300 |
51-100th |
100 |
101-200th |
50 |
Participate |
5 |
First time participate |
200 |
Participate in Biweekly and weekly Contests in the Same Week |
35 |
Overview of the Questions:
Problem |
Topic |
Difficulty |
Time Taken |
No. of Submissions |
---|---|---|---|---|
Check if Strings Can be Made Equal With Operations I |
strings |
Easy |
5 min |
1 |
Check if Strings Can be Made Equal With Operations II |
strings, sorting |
Medium |
12 min |
1 |
Maximum Sum of Almost Unique Subarray |
sliding window, Hash Table, Array |
Medium |
35 min |
3 |
Count K-Subsequences of a String With Maximum Beauty |
string, Hash Table, Math,Combinatorics |
Hard |
Problem 1: Check if Strings Can be Made Equal With Operations I
Difficulty: Easy (3 points)
Pre-requiste to solve that problem: Strings
Approximate time taken to solve by you: 5min
Number of Attempts by you: 1
My Experience: The first question was a very straightforward question. It just took me 5 min to solve the problem.
Accepted Solution: We know that the length of both the strings are constant so we could simply check the even and odd positions separately for equality and if both the conditions satisfies we return true else false;
Time Complexity: O(1) and Space Complexity: O(1).
Problem 2: Check if Strings Can be Made Equal With Operations II
Difficulty: Medium (4 points)
Pre-requiste to solve that problem: String and sorting
Approximate time taken to solve by you: 12 min
Number of Attempts by you: 1
My Experience: Once you get the intuition the question was doable.
Accepted Solution: This question is a more general form of first question. Solved it using extra space as we have to just compare odd and even positions so I took 4 arrays two for string each string ( one for storing even positions and one for odd pos) after storing elements in the array we sort these arrays and compare them if both arrar of both string are same then it is possible for them to be equal otherwise not.
Time Complexity: O(N) and Space Complexity: O(N).
Problem 3: Maximum Sum of Almost Unique Subarray
Difficulty: Medium (5 points)
Pre-requiste to solve that problem: Sliding Window
Approximate time taken to solve by you: 35 min
Number of Attempts by you: 3
My Experience: At first glance I was able to recognize that this question is similar to sliding window problem, but the term almost unique subarrays was a bit confusing for me that’s why I submitted 2 wrong solutions.
Accepted Solution: It was just a simple sliding window problem where we have to find all the subarray with m distinct elements and take their sum. To solve this I used a map to store the frequencies of each element and when size of map becomes equal to m store the sum of all elements and repeat this process for all possible subarrays and return maximum sum obtained.
Time Complexity: O(N) and Space Complexity: O(N).
Problem 4: Count K-Subsequences of a String With Maximum Beauty
Difficulty: Hard (6 points)
Pre-requiste to solve that problem: Combinatorics
Approximate time taken to solve by you: I wasn’t able to solve during the live contest as I dont have knowledge about the required topic.
Conlusion:
I was able to solve 3/4 questions this time. I wasn’t able to solve all 4 of those problems as the 4th problem was a bit hard for me. But I learned a lot. By giving Contest you gain many thing like speed, consistency, motivation(sometimes gets demotivate but that’s part of the journey), time management, pressure handling,new concepts etc. which teach us a lot.
Keep Hustling, Keep Coding!!!!!!!!!!