Skip to content

Instantly share code, notes, and snippets.

@u8989332
u8989332 / LeetCode8.cs
Created October 29, 2020 08:03
LeetCode - 8 String to Integer (atoi)
using System;
namespace LeetCode8
{
public class Solution {
public int MyAtoi(string s) {
int n = s.Length;
bool isPositive = true;
int i;
for(i = 0 ; i < n;++i){
@u8989332
u8989332 / LeetCode8.cpp
Created October 29, 2020 07:59
LeetCode - 8 String to Integer (atoi)
#include <iostream>
#include <cstdlib>
using namespace std;
class Solution {
public:
int myAtoi(string s) {
int n = s.length();
bool isPositive = true;
int i;
@u8989332
u8989332 / LeetCode125.cs
Created October 14, 2020 01:32
LeetCode - 125 Valid Palindrome
using System;
namespace LeetCode125
{
public class Solution {
private int GetAlphanumericCommonIndex(char c){
int index;
if(c >= 'a' && c <= 'z'){
index = c - 'a';
}
@u8989332
u8989332 / LeetCode125.cpp
Created October 14, 2020 01:32
LeetCode - 125 Valid Palindrome
#include <iostream>
using namespace std;
class Solution {
private:
int getAlphanumericCommonIndex(char c){
int index;
if(c >= 'a' && c <= 'z'){
index = c - 'a';
}
@u8989332
u8989332 / LeetCode242.cs
Created October 13, 2020 14:10
LeetCode - 242 Valid Anagram
using System;
using System.Collections.Generic;
namespace LeetCode242
{
public class Solution {
public bool IsAnagram(string s, string t) {
List<int> sCheck = new List<int>();
List<int> tCheck = new List<int>();
for(int i = 0 ; i < 26;++i){
@u8989332
u8989332 / LeetCode242.cpp
Created October 13, 2020 13:52
LeetCode - 242 Valid Anagram
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
bool isAnagram(string s, string t) {
vector<int> sCheck(26);
vector<int> tCheck(26);
for(int i = 0 ; i < s.length();++i){
@u8989332
u8989332 / LeetCode387.cs
Created October 12, 2020 08:59
LeetCode - 387 First Unique Character in a String
using System;
using System.Collections.Generic;
namespace LeetCode387
{
public class Solution {
public int FirstUniqChar(string s) {
List<List<int>> checkChars = new List<List<int>>();
for(int i = 0 ; i < 26;++i){
checkChars.Add(new List<int>());
}
@u8989332
u8989332 / LeetCode387.cpp
Created October 12, 2020 08:56
LeetCode - 387 First Unique Character in a String
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int firstUniqChar(string s) {
vector<vector<int>> checkChars(26);
for(int i = 0 ; i < s.length();++i){
checkChars[s[i] - 'a'].push_back(i);
@u8989332
u8989332 / LeetCode7.cs
Created October 11, 2020 12:22
LeetCode - 7 Reverse Integer
using System;
namespace LeetCode7
{
public class Solution {
public int Reverse(int x) {
long ans = 0;
while(x != 0){
ans = ans * 10 + (x % 10);
x /= 10;
@u8989332
u8989332 / LeetCode7.cpp
Created October 11, 2020 12:18
LeetCode - 7 Reverse Integer
#include <iostream>
#include <cmath>
#include <climits>
using namespace std;
class Solution {
public:
int reverse(int x) {
long ans = 0;
while(x != 0){