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
theme = GruvboxDarkHard | |
font-family = Noto Sans Mono | |
font-size = 14 | |
font-thicken = false | |
command = /usr/local/bin/fish | |
font-feature = -dlig | |
font-feature = -liga |
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
class Solution { | |
public: | |
/** | |
* @param height: A list of integer | |
* @return: The area of largest rectangle in the histogram | |
*/ | |
int largestRectangleArea(vector<int> &height) { | |
stack<int> heightSt; | |
stack<int> indexSt; // start index | |
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
class Node { | |
public: | |
int key; | |
int val; | |
Node *prev; | |
Node *next; | |
Node (int key, int val, Node *prev = NULL, Node *next = NULL) { | |
this->key = key; | |
this->val = val; |
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
class ValType { | |
public: | |
double val; | |
string sym; | |
ValType () { | |
this->val = 1.0; | |
this->sym = ""; | |
} |
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
class Solution { | |
private: | |
vector<int> nums; | |
public: | |
Solution(vector<int> nums) { | |
this->nums = nums; | |
srand(time(NULL)); | |
} | |
int pick(int target) { |
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
class Solution { | |
public: | |
int integerReplacement(int n) { | |
return helper(n); | |
} | |
private: | |
int helper(long n) { | |
if (n == 1) | |
return 0; |
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
class Solution { | |
public: | |
int maxRotateFunction(vector<int>& A) { | |
int len = A.size(); | |
int sum = 0; | |
int psum = 0; | |
// sum | |
for (int i = 0; i < len; ++i) { | |
sum += A[i]; |
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
class Solution { | |
public: | |
int longestSubstring(string s, int k) { | |
vector<int> count = getCharCount(s); | |
for (int i = 0; i < count.size(); ++i) { | |
char ch = i + 'a'; | |
if (count[i] > 0 && count[i] < k) { | |
int max_len = INT_MIN; | |
vector<string> splits = splitString(s, ch); |
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
class Solution { | |
public: | |
string decodeString(string s) { | |
int len = s.length(); | |
if (len == 0) | |
return s; | |
stack<int> num_st; | |
stack<string> sym_st; |
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
class Solution { | |
public: | |
bool validUtf8(vector<int>& data) { | |
return isValid(data, 0); | |
} | |
private: | |
bool isValid(vector<int> &data, int startIndex) { | |
if (startIndex == data.size()) | |
return true; |
NewerOlder