Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
class Solution {
public:
class Solution {
public:
int maxArea(vector<int> height)
{
int max_area = 0;
int left = 0;
int right = height.size() - 1;
while (left < right)
{
class Solution {
public:
bool isPalindrome(int x)
{
if (x<0) return false;
vector<int> vx;
while (x)
{
vx.push_back(x % 10);
class Solution {
public:
int reverse(int x)
{
auto str = to_string(x);
reverse(str.begin(), str.end());
try
{
return x < 0 ? -stoi(str) : stoi(str);
}
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
class Solution {
public:
string convert(string s, int numRows)
#include <iostream>
#include <string>
#include <bitset>
#include <vector>
using namespace std;
class Solution {
public:
int lengthOfLongestSubstring(string s)
#include <iostream>
struct ListNode
{
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
class Solution
@bunnyadad
bunnyadad / Two_Sum
Last active March 19, 2019 10:23
LeetCode Two Sum
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target)
{
map<int, int> nums_map;
for (size_t i = 0; i < nums.size(); i++)
{
auto complement = target - nums[i];
if (nums_map.find(complement) != nums_map.end()) return {(int)i, nums_map[complement]};
#include <iostream>
#include <string>
#include <vector>
#include <regex>
using namespace std;
class Font
{
public:
#include <iostream>
#include <string>
#include <map>
using namespace std;
size_t isMine(char c)
{
return c == '*' ? 1 : 0;
}