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
type Alfa = 'a' | 'b' | 'c' | 'd' | |
| 'e' | 'f' | 'g' | 'h' | 'i' | |
| 'j' | 'k' | 'l' | 'm' | 'n' | |
| 'o' | 'p' | 'q' | 'r' | 's' | |
| 't' | 'u' | 'v' | 'w' | 'x' | |
| 'y' | 'z'; | |
type Numeric = '1' | '2' | '3' | '4' | |
| '5' | '6' | '7' | '8' | '9'; |
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
/** | |
* 8 | |
* / \ | |
* 6 25 | |
* / \ / \ | |
* 4 8 15 30 | |
* \ | |
* 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
/** | |
* 8 root = 10 | root = <- deleteNode(10) -> | |
* / \ | |
* 6 25 | |
* / \ / \ | |
* 4 8 15 30 | |
* \ | |
* 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
class Node { | |
public next: Node = null; | |
constructor( | |
public value: number | |
) {} | |
} | |
class Queue { | |
private front: Node = null; |
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 Nodo { | |
public next: Nodo = null; | |
constructor( | |
public value: number | |
) {} | |
} | |
class Stack { |
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
/** | |
* ht.set('myKey2', value); | |
* | | |
* v | |
* hash(key) -> index | |
* | | |
* v | |
* 0| (myKey2, value) -> (myKey, value) -> null, | |
* 1| , | |
* 2| , |
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
import random | |
class RandomizedSet: | |
""" | |
set = { 1: 0, 2: 1 } | |
indexes = { 0: 1, 1: 2} | |
""" | |
def __init__(self): |
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 rangeSumBST(self, root: TreeNode, L: int, R: int) -> int: | |
_sum = 0 | |
if root: | |
if root.val >= L and root.val <= R: | |
_sum += root.val | |
if root.val <= R: | |
_sum += self.rangeSumBST(root.right, L, R) |
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 List<List<String>> groupAnagrams(String[] strs) { | |
if (strs.length == 0) return new ArrayList(); | |
Map<String, List> ans = new HashMap<String, List>(); | |
int[] count = new int[26]; | |
for (String s : strs) { | |
Arrays.fill(count, 0); | |
for (char c : s.toCharArray()) count[c - 'a']++; | |
StringBuilder sb = new StringBuilder(""); |
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 groupAnagrams(self, strs: List[str]) -> List[List[str]]: | |
result = [] | |
groups = {} | |
for word in strs: | |
wordFrecuency = self.__getDictFrecuency(word) # O(n) -> {...} | |
groupIndex = self.__belongsToAGroup(groups, wordFrecuency) # O(groups.length + wordFrecuency.length) | |
if groupIndex > -1: |
NewerOlder