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.