Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Maximum profit
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { // Get the maximum profit for stock prices that occur in a day var prices = new Int32[] { 40, 32, 20, 50, 100 }; var max = prices[0]; var min = max; for (var i = 0; i < prices.Length; i++) { var curr = prices[i]; if (curr > max) { max = curr; } if (curr < min) { min = curr; } } Console.WriteLine(String.Format("Maximum profit is: ${0}", max-min)); } } }
run
|
edit
|
history
|
help
0
Find the count of subsets with given difference
enum flag comparison
Converting a string to byte-array without using an encoding (byte-by-byte)
Print("This is a Test")
Uri builder
Difference between Equals and ==
Just tries to add/remove items to the list
Test
C# first code
IntNull