Skip to content

Instantly share code, notes, and snippets.

View eclipselu's full-sized avatar
🏠
Working from home

Lu Dang eclipselu

🏠
Working from home
  • Kitchener, Ontario
View GitHub Profile
/**
* Definition for an interval.
* struct Interval {
* int start;
* int end;
* Interval() : start(0), end(0) {}
* Interval(int s, int e) : start(s), end(e) {}
* };
*/

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
class Solution {
public:
bool is_par(string s) {
int len = s.length();
for (int i = 0; i < len / 2; i++) {
if (s[i] != s[len - 1 - i])
return false;
}
return true;
struct Status {
int start;
int cuts;
Status(int start_, int cuts_): start(start_), cuts(cuts_) {}
};
class Solution {
public:
bool isPar(string str, int low, int high, vector<vector<bool> > &dp) {
class Solution {
public:
int maxProfit(vector<int> &prices) {
// Note: The Solution object is instantiated only once and is reused by each test case.
if (prices.empty())
return 0;
int len = prices.size();
int min_idx = 0, prof = 0;
class Solution {
public:
int maxProfit(vector<int> &prices) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
if (prices.empty())
return 0;
int len = prices.size();
int i = 0, prof = 0;
struct Status {
int pos;
int prof;
Status(int pos_, int prof_): pos(pos_), prof(prof_) {}
};
class Solution {
public:
int maxProfit(vector<int> &prices) {
// IMPORTANT: Please reset any member data you declared, as
class Solution {
public:
void nextPermutation(vector<int> &num) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
int len = num.size();
if (len < 2)
return ;
int i = len - 2;
class Solution {
public:
int numTrees(int n) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
vector<int> ans(n + 1, 0);
ans[1] = ans[0] = 1;
for (int i = 2; i <= n; i++)
for (int j = 1; j <= i; j++)
class Solution {
public:
int minimumTotal(vector<vector<int> > &triangle) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
if (triangle.empty())
return 0;
int m = triangle.size();
for (int i = m - 2; i >= 0; i--)