This file contains 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++: | |
class Solution { | |
public: | |
int search(int A[], int n, int target) { | |
// Start typing your C/C++ solution below | |
// DO NOT write int main() function | |
int low=0; | |
int high=n-1; | |
int mid; | |
while(low<=high){ |
This file contains 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++: | |
class Solution { | |
public: | |
bool search(int A[], int n, int target) { | |
// Start typing your C/C++ solution below | |
// DO NOT write int main() function | |
int low=0; | |
int high=n-1; | |
int mid; | |
while(low<=high){ |
This file contains 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++: | |
class Solution { | |
public: | |
int maximalRectangle(vector<vector<char> > &matrix) { | |
// Start typing your C/C++ solution below | |
// DO NOT write int main() function | |
int m=matrix.size(); | |
if(m==0) return 0; | |
int n=matrix[0].size(); | |
if(n==0) return 0; |
This file contains 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++: | |
class Solution { | |
public: | |
int removeDuplicates(int A[], int n) { | |
// Start typing your C/C++ solution below | |
// DO NOT write int main() function | |
if(n==0||n==1) return n; | |
int min=A[0]-1; | |
for(int i=n;i>0;i--) | |
if(A[i]==A[i-1]) |
This file contains 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++: | |
class Solution { | |
public: | |
int removeDuplicates(int A[], int n) { | |
// Start typing your C/C++ solution below | |
// DO NOT write int main() function | |
if(n==0||n==1) return n; | |
int min=A[0]-1; | |
int cur=A[0]; | |
int count=0; |
This file contains 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++: | |
/** | |
* Definition for singly-linked list. | |
* struct ListNode { | |
* int val; | |
* ListNode *next; | |
* ListNode(int x) : val(x), next(NULL) {} | |
* }; | |
*/ | |
class Solution { |
This file contains 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++: | |
/** | |
* Definition for singly-linked list. | |
* struct ListNode { | |
* int val; | |
* ListNode *next; | |
* ListNode(int x) : val(x), next(NULL) {} | |
* }; | |
*/ | |
class Solution { |
This file contains 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++: | |
class Solution { | |
public: | |
vector<vector<int> > combine(int n, int k) { | |
// Start typing your C/C++ solution below | |
// DO NOT write int main() function | |
vector<vector<int>> results; | |
vector<int> result; | |
if(n<=0||k<=0||n<k) return results; | |
comb(n,k,results,result,1,0); |
This file contains 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++: | |
class Solution { | |
public: | |
vector<vector<int> > combinationSum(vector<int> &candidates, int target) { | |
// Start typing your C/C++ solution below | |
// DO NOT write int main() function | |
vector<vector<int>> results; | |
if(candidates.size()==0) return results; | |
sort(candidates.begin(),candidates.end()); | |
vector<int> result; |
This file contains 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++: | |
class Solution { | |
public: | |
vector<vector<int> > combinationSum2(vector<int> &candidates, int target) { | |
// Start typing your C/C++ solution below | |
// DO NOT write int main() function | |
vector<vector<int>> results; | |
if(candidates.size()==0) return results; | |
sort(candidates.begin(),candidates.end()); | |
vector<int> result; |
OlderNewer