Problem statementConsider a n*n matrix. Suppose each cell in the matrix has a value assigned. We can go from each cell in row i to a diagonally higher cell in row i+1 only [i.e from cell(i, j) to cell(i+1, j-1) and cell(i+1, j+1) only]. Find the path from the top row to the bottom row following the aforementioned condition such that the maximum sum is obtainedExampleIf given input is: { {5, 6, 1, 17}, {-2, 10, 8, -1}, { 3, -7, -9, 4}, {12, -4, 2, 2} }the maximum sum is (17 + 8 + 4 ... Read More
Problem statementGiven a right triangle of numbers, find the largest of the sum of numbers that appear on the paths starting from the top towards the base, so that on each path the next number is located directly below or below-and-one-place-to-the-rightExampleIf given input is: 3 4 5 1 10 7 Then maximum sum is 18 as (3 + 5 + 10).AlgorithmThe idea is to find largest sum ending at every cell of last row and return maximum of these sums.We can recursively compute these sums by recursively considering above two cellsSince there are overlapping sub-problems, we use dynamic programming to ... Read More
Problem statementGiven an array of N numbers, the task is to find the maximum sum that can be obtained by adding numbers with the same number of set bitsExampleIf input array is {2, 5, 8, 9, 10, 7} then output would be 14 −Number of set bits in 2 is 1Number of set bits in 5 is 2Number of set bits in 8 is 1Number of set bits in 9 is 2Number of set bits in 10 is 2Number of set bits in 7 is 3Then sum of (5 + 9 + 10) is 24 whose number of set bits ... Read More
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
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
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
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
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.
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
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.
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP