Skip to content

Instantly share code, notes, and snippets.

class Solution {
public:
int maxArea(vector<int> &height) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
int size = height.size();
int left = 0;
class Solution {
public:
string intToRoman(int num) {
string roman[13] = {"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
int cost[13] = {1000,900,500,400,100,90,50,40,10,9,5,4,1};
string result;
while(num > 0) {
for(int i = 0; i < 13; i++) {
int times = num/cost[i];
class Solution {
public:
int romanToInt(string s) {
int len = s.length();
int result = 0;
map<char, int> myMap;
myMap['I'] = 1;
myMap['V'] = 5;
class Solution {
public:
string longestCommonPrefix(vector<string> &strs) {
string prefix;
int size = strs.size();
if(size <= 0) return prefix ;
class Solution {
public:
vector<vector<int> > threeSum(vector<int> &num) {
sort(num.begin(), num.end());
int size = num.size();
vector<vector<int> > results;
class Solution {
public:
int threeSumClosest(vector<int> &num, int target) {
int gap = INT_MAX;
sort(num.begin(), num.end());
int size = num.size();
class Solution {
public:
char letter[10][4] ={{' ',' ',' ',' '},
{' ',' ',' ',' '},
{'a','b','c',' '},
{'d','e','f',' '},
{'g','h','i',' '},
{'j','k','l',' '},
{'m','n','o',' '},
{'p','q','r','s'},
class Solution {
public:
vector<vector<int> > fourSum(vector<int> &num, int target) {
// Note: The Solution object is instantiated only once and is reused by each test case.
vector<int> tmp;
vector<vector<int>> results;
if(num.empty()) return results;
sort(num.begin(), num.end());
for(int i=0; i<num.size(); i++)
{
class Solution {
public:
ListNode *removeNthFromEnd(ListNode *head, int n) {
if(head == NULL) return head;
ListNode * dummy = new ListNode(-1);
dummy->next = head;
class Solution {
public:
bool isValid(string s) {
int len = s.length();
if(len <= 1) return false;
stack<char> myStack;