This file contains hidden or 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
""" | |
Example 1: | |
Input: transactions = [[0,1,10],[2,0,5]] | |
Output: 2 | |
Explanation: | |
Person #0 gave person #1 10. | |
Person #2 gave person #0 5. | |
Two transactions are needed. One way to settle the debt is person #1 pays person #0 and #2 5 each. |
This file contains hidden or 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
# Input: "{a,b}c{d,e}f" | |
# Output: ["acdf","acef","bcdf","bcef"] | |
# "{a,b,c}d{e,f}" represents the list ["ade", "adf", "bde", "bdf", "cde", "cdf"] | |
# Input: "abcd" | |
# Output: ["abcd"] | |
from collections import deque |
This file contains hidden or 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
sourceCode = "num foo;" | |
replacements = [ | |
{ "start": 0, "before": "num", "after": "String" }, | |
{ "start": 4, "before": "foo", "after": "bar" } | |
] | |
def replace(sourceCode,replacements): | |
record = {} | |
for item in replacements: |
This file contains hidden or 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 numDistinctIslands(self, grid) -> int: | |
self.dirs = { | |
"U":(-1,0), | |
"D":(1,0), | |
"L":(0,-1), | |
"R":(0,1), | |
} |
This file contains hidden or 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
# Online Python - IDE, Editor, Compiler, Interpreter | |
""" | |
Given a string s , find the length of the longest substring t that contains at most 2 distinct characters. | |
Example 1: | |
Input: "eceba" | |
Output: 3 |
This file contains hidden or 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
package adventofcode | |
import "testing" | |
var input18 = []string{ | |
"R 4 (#4b18e0)", | |
"U 4 (#0b4f93)", | |
"R 4 (#6d70b0)", | |
"U 12 (#86edc3)", | |
"R 4 (#435460)", |
This file contains hidden or 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
package adventofcode | |
import ( | |
"strconv" | |
"strings" | |
) | |
func day18Part1(input []string) int { | |
// prepare a grid as input, lets assume maximum length is 500 |
This file contains hidden or 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
package adventofcode | |
import ( | |
"slices" | |
"strconv" | |
"strings" | |
) | |
/* | |
* |
This file contains hidden or 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
package adventofcode | |
import "testing" | |
var input13 = []string{ | |
"##...##....##", | |
"..#.##....#.#", | |
"..#.##....#.#", | |
"##.#.##....##", | |
"#####.#..###.", |
This file contains hidden or 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
package adventofcode | |
import ( | |
"fmt" | |
"strings" | |
) | |
func day13Part1(input []string) int { | |
parsedInput := processInput(input) |
NewerOlder