public class MaximumSubarray
{
private static int Max(int a, int b)
{
return a > b ? a : b;
}
static int MaxSubArray(int[] input, int n)
{
int max = input[0];
int currentMax = input[0];
for (int i = 1; i < n; i++)
{
...
Use
Update the object name which is stored in reference
SYNOPSIS
git update-ref [-m <reason>] (-d <ref> [<oldvalue>] | [--no-deref] [--create-reflog] <ref> <newvalue> [<oldvalue>] | --stdin [-z])
General Syntax
Dereferencing the symbolic refs, update th...
(input)
output = 0
for cycleStart from 0 to length(array) - 2
item = array[cycleStart]
pos = cycleStart
for i from cycleStart + 1 to length(array) - 1
if array[i] < item:
pos += 1
if pos == cycleStart:
continue
while item == array[pos]:
...
public class CycleSort
{
public static void SortCycle(int[] input)
{
for (var i = 0; i < input.Length; i++)
{
var item = input[i];
var position = i;
do
{
var k = input.Where((t, j) => position != ...
Constraints:
Input (an array to be sorted)
Number of element in input (n)
Keys in the range of 0..k-1 (k)
Count (an array of number)
Pseudocode:
for x in input:
count[key(x)] += 1
total = 0
for i in range(k):
oldCount = count[i]
count[i] = total
total += oldCount
for...
public class CountingSort
{
public static void SortCounting(int[] input, int min, int max)
{
var count = new int[max - min + 1];
var z = 0;
for (var i = 0; i < count.Length; i++)
count[i] = 0;
foreach (int i in input)
co...
public class HeapSort
{
public static void Heapify(int[] input, int n, int i)
{
int largest = i;
int l = i + 1;
int r = i + 2;
if (l < n && input[l] > input[largest])
largest = l;
if (r < n && input[r] ...
public class PigeonholeSort
{
private static void SortPigeonhole(int[] input, int n)
{
int min = input[0], max = input[n];
for (int i = 1; i < n; i++)
{
if (input[i] < min) min = input[i];
if (input[i] > max) max = input[i];
...
insertSort :: Ord a => [a] -> [a]
insertSort [] = []
insertSort (x:xs) = insert x (insertSort xs)
insert :: Ord a => a-> [a] -> [a]
insert n [] = [n]
insert n (x:xs) | n <= x = (n:x:xs)
| otherwise = x:insert n xs
public class CatalanNumber
{
public static int Main(int number)
{
int result = 0;
if (number <= 1) return 1;
for (int i = 0; i < number; i++)
{
result += Main(i)*Main(number - i - 1);
}
return result;
}
}
quickSort :: Ord a => [a] -> [a]
quickSort [] = []
quickSort (x:xs) = quickSort [ y | y <- xs, y <= x ]
++ [x]
++ quickSort [ z | z <- xs, z > x ]
public class PascalsTriangle
{
static void PascalTriangle(int n)
{
for (int line = 1; line <= n; line++)
{
int c = 1;
for (int i = 1; i <= line; i++)
{
Console.WriteLine(c);
c = c * (line - i)...
Routes in Laravel are case-sensitive. It means that a route like
Route::get('login', ...);
will match a GET request to /login but will not match a GET request to /Login.
In order to make your routes case-insensitive, you need to create a new validator class that will match requested URLs agains...
For full documentation, run the command:
godoc -http=:<port-number>
For a tour of Go (highly recommended for beginners in the language):
go tool tour
The two commands above will start web-servers with documentation similar to what is found online here and here respectively.
For quick ...
Background Theory:
Bresenham’s Line Drawing Algorithm is an efficient and accurate raster line generating algorithm developed by Bresenham. It involves only integer calculation so it is accurate and fast. It can also be extended to display circles another curves.
In Bresenham line drawing algorith...
The Shortest Common Super Sequence is a problem closely related to the longest common subsequence, which you can use as an external function for this task. The shortest common super sequence problem is a problem closely related to the longest common subsequence problem.
A shortest common superseque...
public class ShortestCommonSupersequence
{
private static int Max(int a, int b)
{
return a > b ? a : b;
}
private static int Lcs(string x, string y, int m, int n)
{
var l = new int[m + 1, n + 1];
for (var i = 0; i <= m; i++)
{...