Skip to content

Instantly share code, notes, and snippets.

"""
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.
# 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
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:
class Solution:
def numDistinctIslands(self, grid) -> int:
self.dirs = {
"U":(-1,0),
"D":(1,0),
"L":(0,-1),
"R":(0,1),
}
# 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
package adventofcode
import "testing"
var input18 = []string{
"R 4 (#4b18e0)",
"U 4 (#0b4f93)",
"R 4 (#6d70b0)",
"U 12 (#86edc3)",
"R 4 (#435460)",
package adventofcode
import (
"strconv"
"strings"
)
func day18Part1(input []string) int {
// prepare a grid as input, lets assume maximum length is 500
package adventofcode
import (
"slices"
"strconv"
"strings"
)
/*
*
package adventofcode
import "testing"
var input13 = []string{
"##...##....##",
"..#.##....#.#",
"..#.##....#.#",
"##.#.##....##",
"#####.#..###.",
package adventofcode
import (
"fmt"
"strings"
)
func day13Part1(input []string) int {
parsedInput := processInput(input)