codechef STRBIT – How to Repaint a Fence

you can find the problem statement here.

this question is just a modified/difficult model of spoj pebble.

as they introduced an extra condition k, I solved it using segment tree with lazy propagation. O(n*log(n))

but we can also solve it in O(n) as mentioned in its codechef-editorial.

https://gist.github.com/43ea97184c89665af603

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s