Leetcode Biweekly Contest 31 by justyy

View this thread on steempeak.com
· @justyy ·
$20.74
Leetcode Biweekly Contest 31
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.

![image.png](https://cdn.steemitimages.com/DQmSYHXx4SCNu39BC8HovjteMYc5FF6s3DFys2iL9XcVPHz/image.png)

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](https://helloacm.com) in more details soon.

Although the contest has ended, you can try to participate on the virtual contest.

<hr/>

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***
https://steemyy.com/images/vote-for-justyy.jpg
<BR/>
**Alternatively, you could [proxy to me](https://steemyy.com/witness-voting/?witness=justyy&action=proxy)  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](https://steemyy.com)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 87 others
properties (23)
post_id86,833,219
authorjustyy
permlinkleetcode-biweekly-contest-31
categorywitness-category
json_metadata{"tags":["witness-category","programming","whalepower","algorithms","coding","leetcode","contest","codeonsteem"],"image":["https:\/\/cdn.steemitimages.com\/DQmSYHXx4SCNu39BC8HovjteMYc5FF6s3DFys2iL9XcVPHz\/image.png","https:\/\/steemyy.com\/images\/vote-for-justyy.jpg"],"links":["https:\/\/leetcode.com\/contest\/biweekly-contest-31","https:\/\/leetcode.com\/contest\/biweekly-contest-31\/problems\/count-odd-numbers-in-an-interval-range","https:\/\/leetcode.com\/contest\/biweekly-contest-31\/problems\/number-of-sub-arrays-with-odd-sum\/","https:\/\/leetcode.com\/contest\/biweekly-contest-31\/problems\/number-of-good-ways-to-split-a-string\/","https:\/\/leetcode.com\/contest\/biweekly-contest-31\/problems\/minimum-number-of-increments-on-subarrays-to-form-a-target-array\/","https:\/\/helloacm.com","https:\/\/steemit.com\/~witnesses","https:\/\/steemyy.com\/witness-voting\/?witness=justyy&action=proxy","https:\/\/steemyy.com\/witness-voting\/?witness=justyy","https:\/\/steemyy.com"],"app":"steemit\/0.2","format":"markdown"}
created2020-07-25 17:15:12
last_update2020-07-25 17:15:12
depth0
children0
net_rshares32,240,007,438,331
last_payout2020-08-01 17:15:12
cashout_time1969-12-31 23:59:59
total_payout_value10.838 SBD
curator_payout_value9.905 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length2,602
author_reputation2,057,469,156,047,835
root_title"Leetcode Biweekly Contest 31"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (151)