I have recently started to attend the online coding contest. Leetcode has held weekly contests on Sunday early mornings - which isn’t ideal for coders living in Europe.
However, they have biweekly contests, which is run the Sat 3:30 to 5:30 (BST) every two weeks.
Today’s contest: https://leetcode.com/contest/biweekly-contest-31
I have managed to solve 3 puzzles in 30 minutes, however, failed to solve the fourth puzzle (difficulty level) in next hour.
The programming language I choose is C++. I have 2 Wrong Answer submission for Problem 2 - which adds total 10 minutes time penalization.
The fourth puzzle is not that difficult - it is a pity that I didn’t get it - and my ranking is expected to drop.
Count Odd Numbers in an Interval Range
https://leetcode.com/contest/biweekly-contest-31/problems/count-odd-numbers-in-an-interval-range
Easy Math, we can simplify the problem by adjusting the low/high acordingly. For example, when low is even, we can increment the low and the result will be the same.
Number of Sub-arrays With Odd Sum
https://leetcode.com/contest/biweekly-contest-31/problems/number-of-sub-arrays-with-odd-sum/
Dynamic Programming or Prefix Sum. Count the even sum or odd sum and add them.
Number of Good Ways to Split a String
https://leetcode.com/contest/biweekly-contest-31/problems/number-of-good-ways-to-split-a-string/
Use two arrays to store the number of occurencies for each character. There are O(N) ways to split a string.
Minimum Number of Increments on Subarrays to Form a Target Array
https://leetcode.com/contest/biweekly-contest-31/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/
Accumulate the difference between neigbour numbers, this can be done in O(N), four lines of code.
I’ll share the solutions on the blog in more details soon.
Although the contest has ended, you can try to participate on the virtual contest.
Every little helps! I hope this helps!
Steem On!~
If you like my work, please consider voting for me, thanks!
https://steemit.com/~witnesses type in justyy and click VOTE
Alternatively, you could proxy to me if you are too lazy to vote!
Also: you can vote me at the tool I made: https://steemyy.com/witness-voting/?witness=justyy
Visit me at: https://steemyy.com
This page is synchronized from the post: ‘Leetcode Biweekly Contest 31’