Skip to content

Instantly share code, notes, and snippets.

View SerialForBreakfast's full-sized avatar

Joe SerialForBreakfast

View GitHub Profile

Keybase proof

I hereby claim:

  • I am serialforbreakfast on github.
  • I am joeblender (https://keybase.io/joeblender) on keybase.
  • I have a public key ASDZh5zzzUcdKJraiJvzOoOGISdXeik-axCsoelJiCLXPAo

To claim this, I am signing this object:

@SerialForBreakfast
SerialForBreakfast / MaxProfitQuestion.swift
Created May 19, 2019 06:27
Find the largest margin to place a buy and sell order over a day.
import UIKit
let stockPrices:[Int] = [10, 7, 5, 8, 11, 9]
func getMaxProfit(from: [Int]) -> Int {
var bestProfit: Int = 0
var newSell: Int = 0
var newBuy: Int = Int.max
var newSpread: Int = 0