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
#!/usr/bin/env python3 | |
import sys | |
numbers = {"zero": 0, | |
"one": 1, | |
"two": 2, | |
"three": 3, | |
"four": 4, | |
"five": 5, |
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
public class List { | |
private Node start, end; | |
private int size; | |
public void add(Object variable){ | |
if(start==null){ | |
start = end = new Node(variable); | |
} | |
else{ | |
Node temporary = new Node(variable); |
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
# https://leetcode.com/explore/featured/card/august-leetcoding-challenge/550/week-2-august-8th-august-14th/3419/ | |
class Solution: | |
def titleToNumber(self, s: str) -> int: | |
res = 0 | |
power = 0 | |
for i in reversed(range(len(s))): | |
res += int(ord(s[i]) - ord('A') + 1) * (26**power) | |
power += 1 | |
return res |
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: | |
def detectCapitalUse(self, word: str) -> bool: | |
if word.lower() == word: | |
return True | |
if word[0].upper() + word[1:].lower() == word: | |
return True | |
if word.upper() == word: | |
return True |
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 WordDictionary: | |
def __init__(self): | |
""" | |
Initialize your data structure here. | |
""" | |
self.root = TrieNode() | |
def addWord(self, word: str) -> None: |
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: | |
def isPowerOfFour(self, num: int) -> bool: | |
i = 0 | |
for i in range(32): | |
if (1 << i) & num and (1 << i) == num and i % 2 == 0: | |
return True | |
return False |
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: | |
def isPalindrome(self, s: str) -> bool: | |
def isValid(c: int) -> bool: | |
if (c >= ord('0') and c <= ord('9')) or \ | |
(c >= ord('A') and c <= ord('Z')) or \ | |
(c >= ord('a') and c <= ord('z')): | |
return True | |
return False | |
def sameChar(i: int, j: int) -> bool: |
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
// https://leetcode.com/explore/challenge/card/july-leetcoding-challenge/548/week-5-july-29th-july-31st/3407/ | |
import java.util.*; | |
public class Solution { | |
TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>(); | |
public int climbStairs(int n) { | |
if(n == 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
// https://leetcode.com/explore/challenge/card/july-leetcoding-challenge/548/week-5-july-29th-july-31st/3406/ | |
import java.util.*; | |
class Solution { | |
public List<String> wordBreak(String s, List<String> dict) { | |
HashMap<String, ArrayList<String>> dp = new HashMap<String, ArrayList<String>>(); | |
return dfs(s, new HashSet(dict), dp); | |
} | |
ArrayList<String> dfs(String s, Set<String> dict, HashMap<String, ArrayList<String>> dp) |
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
# https://leetcode.com/explore/challenge/card/july-leetcoding-challenge/546/week-3-july-15th-july-21st/3395/ | |
class Solution(object): | |
def addBinary(self, a: str, b: str) -> str: | |
return self.add(a, b, len(a) - 1, len(b) - 1, 0) | |
def add(self, a: str, b: str, i: int, j: int, c: int): | |
if c == 0 and i < 0 and j < 0: | |
return '' | |
NewerOlder