This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
OlderNewer