Skip to content

Instantly share code, notes, and snippets.

View wilderfield's full-sized avatar

Bryan Lozano wilderfield

View GitHub Profile
@wilderfield
wilderfield / hotel.cpp
Last active August 28, 2022 22:39
Hotel Stops
// C++11
// State subproblem in words
// Common case is to apply same problem to prefix of input
// That case seems to hold here
// Let dp[i] be the minimum cost of ending a night at position i
// Identify recursion
@wilderfield
wilderfield / craziness.cpp
Last active October 21, 2023 00:46
Return the minimum number of elements to be removed to make a given array of numbers sorted.
#include <vector>
#include <iostream>
#include <limits.h>
#include <algorithm>
using namespace std;
// Let dp(i,j) = minimum number of elements excluded from nums[0:i] inclusive to keep it sorted,
// given nums[j] is already included and must be the maximum element