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
#include <stdio.h> | |
#include <vector> | |
#include <algorithm> | |
#include <map> | |
using namespace std; | |
class TestData | |
{ |
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
#define GET_TWO_OPERANDS { \ | |
y = operands.top(); operands.pop(); \ | |
x = operands.top(); operands.pop(); } | |
class Solution { | |
public: | |
int evalRPN(vector<string> &tokens) | |
{ | |
stack<int> operands; |
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
class Solution { | |
public: | |
void reverseWords(string &s) { | |
int N = s.size(); | |
string ans(N + 1, '\0'); | |
int state = 0; | |
bool first_word = true; | |
int j = 0; | |
for (int i = N - 1; i >= 0; --i) { |
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
#define _CRTDBG_MAP_ALLOC | |
#include <crtdbg.h> | |
#include <opencv2/opencv.hpp> | |
#include "opencv2/core/core.hpp" | |
#include "opencv2/imgproc/imgproc.hpp" | |
#include "opencv2/calib3d/calib3d.hpp" | |
#include "opencv2/highgui/highgui.hpp" | |
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
#define _CRTDBG_MAP_ALLOC | |
#include <crtdbg.h> | |
#include <opencv2/opencv.hpp> | |
#include "opencv2/core/core.hpp" | |
#include "opencv2/imgproc/imgproc.hpp" | |
#include "opencv2/calib3d/calib3d.hpp" | |
#include "opencv2/highgui/highgui.hpp" | |
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
#define _CRTDBG_MAP_ALLOC | |
#include <crtdbg.h> | |
#include <opencv2/opencv.hpp> | |
#include "opencv2/core/core.hpp" | |
#include "opencv2/imgproc/imgproc.hpp" | |
#include "opencv2/calib3d/calib3d.hpp" | |
#include "opencv2/highgui/highgui.hpp" | |
int main(void) |
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
/** | |
* Definition for a point. | |
* struct Point { | |
* int x; | |
* int y; | |
* Point() : x(0), y(0) {} | |
* Point(int a, int b) : x(a), y(b) {} | |
* }; | |
*/ | |
bool operator<(const Point &p1, const Point &p2) { |
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
typedef ListNode LNode; | |
class Solution { | |
public: | |
ListNode *insertionSortList(ListNode *head) { | |
if (!head) return NULL; | |
LNode *newHead=head; LNode *p=head->next; | |
newHead->next=NULL; | |
while (p) { | |
LNode *cur=p; p=p->next; | |
newHead=insert(newHead, cur); |
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
/** | |
* Definition for singly-linked list. | |
* struct ListNode { | |
* int val; | |
* ListNode *next; | |
* ListNode(int x) : val(x), next(NULL) {} | |
* }; | |
*/ | |
typedef ListNode LNode; | |
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
class Solution { | |
public: | |
char *strStr(char *haystack, char *needle) { | |
if (!haystack || !needle) return NULL; | |
int N=strlen(needle); | |
if (N<1) (haystack[0]=='\0') ? haystack : NULL; | |
int *next=new int[N]; | |
computeNext(needle, next, N); | |
char *p=haystack; int j=0; |
NewerOlder