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 climbStairs(int n) { | |
| if(n <= 2) return n; | |
| int a = 1; | |
| int b = 2; | |
| int result = 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: | |
| string simplifyPath(string path) { | |
| int len = path.length(); | |
| string result; | |
| if(len == 0) return result; | |
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 minDistance(string word1, string word2) { | |
| if(word1.length() == 0) return word2.length(); | |
| if(word2.length() == 0) return word1.length(); | |
| int len1 = word1.length(); | |
| int len2 = word2.length(); | |
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: | |
| void setZeroes(vector<vector<int> > &matrix) { | |
| int row = matrix.size(); | |
| if(row == 0) return; | |
| int col = matrix[0].size(); | |
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 searchMatrix(vector<vector<int> > &matrix, int target) { | |
| int row = matrix.size(); | |
| if(row == 0) return false; | |
| int col = matrix[0].size(); | |
| int x = 0; int y = col -1; |
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: | |
| void swap(int & a, int & b) { | |
| int temp = a; | |
| a = b; | |
| b = temp; | |
| } | |
| void sortColors(int A[], int n) { | |
| int first = 0; | |
| int second = n - 1; |
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 minWindow(string S, string T) { | |
| string result; | |
| int s = S.length(); | |
| int t = T.length(); | |
| if(s == 0 || t == 0) return result; | |
| map<char, int> need; |
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: | |
| vector<vector<int> > combine(int n, int k) { | |
| vector<vector<int> > results; | |
| vector<int> entry; | |
| combineHelper(n, k, entry, results, 1); | |
| return results; | |
| } |
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: | |
| vector<vector<int> > subsets(vector<int> &S) { | |
| sort(S.begin(), S.end()); | |
| vector<int> entry; | |
| vector<vector<int> > results; |
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 getithBit(int n, int i) { | |
| return n & 1<<i; | |
| } | |
| vector<vector<int> > subsets(vector<int> &S) { | |