Maximum Subarray Sum in O(N) Using Prefix Sum in C++

Narendra Kumar
Updated on 30-Jan-2020 12:05:28

767 Views

Problem statementGiven an Array of Positive and Negative Integers, find out the Maximum Subarray Sum in that ArrayExampleIf input array is − {-12, -5, 4, -1, -7, 1, 8, -3} then output is 9AlgorithmCalculate the prefix sum of the input array.Initialize− min_prefix_sum = 0, res = -infiniteMaintain a loop for i = 0 to n. (n is the size of the input array).cand = prefix_sum[i] – miniIf cand is greater than res (maximum subarray sum so far), then update res by cand.If prefix_sum[i] is less than min_prefix_sum (minimum prefix sum so far), then update min_prefix_sum by prefix_sum[i].Return resExample Live Demo#include ... Read More

Set the Color of Text with CSS

Srinivas Gorla
Updated on 30-Jan-2020 10:39:57

237 Views

To set the color of a text, use the color property.ExampleYou can try to run the following code to learn how to work with the color property in CSS:                            ANTARTICA is a continent          

Usage of Text Decoration Property in CSS

varun
Updated on 30-Jan-2020 10:37:48

95 Views

The text-decoration property is used to underline, overline, and strikethrough text.ExampleThe following example demonstrates how to decorate a text. Possible values are none, underline, overline, line-through, blink.                            This will be underlined                      This will be striked through.                      This will have a over line.                      This text will have blinking effect          

Set the Direction of Text with CSS

karthikeya Boyini
Updated on 30-Jan-2020 10:37:20

141 Views

The direction property is used to set the text direction. Possible values are ltr or rtl.ExampleYou can try to run the following code to set the text direction with CSS:                            This text will be renedered from right to left          

Set the Font Stretch of an Element with CSS

Samual Sam
Updated on 30-Jan-2020 10:36:52

55 Views

To set the font-stretch of an element, use the font-stretch property. Possible values could be normal, wider, narrower, ultra-condensed, extra-condensed, condensed, semi-condensed, semi-expanded, expanded, extra-expanded, ultra-expanded.                            If this doesn't appear to work, it is likely that your computer doesn't have a          condensed or expanded version of the font being used.          

Usage of Font Variant Property in CSS

Sreemaha
Updated on 30-Jan-2020 10:36:27

77 Views

The font-variant property is used to create a small-caps effect. Possible values are normal and small-caps.                            This text will be rendered as small caps          

Usage of Font Weight Property in CSS

Abhinaya
Updated on 30-Jan-2020 10:36:02

76 Views

The font-weight property is used to increase or decrease how bold or light a font appears. The font-weight property provides the functionality to specify how bold a font is. Possible values could be normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900.                   This font is bold.       This font is bolder.       This font is 500 weight.    

Font Size Adjust of an Element with CSS

Giri Raju
Updated on 30-Jan-2020 10:35:27

225 Views

This property enables you to adjust the x-height to make fonts more legible. Possible value could be any number.Example                            Asia is a continent.          

Set the Font Family with CSS

vanithasree
Updated on 30-Jan-2020 10:34:23

462 Views

The font-family property is used to change the face of a font. Possible value could be any font family name.                            This text is rendered in either georgia, garamond, or the default serif font          depending on which font you have at your system.          

Usage of Font Size Property in CSS

usharani
Updated on 30-Jan-2020 10:22:35

172 Views

The font-size property is used to increase or decrease the size of a font. The font-size property is used to control the size of fonts. Possible values could be xx-small, x-small, small, medium, large, x-large, xx-large, smaller, larger, size in pixels or in %.                   This font size is 15 pixels       This font size is small       This font size is large    

Advertisements