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
from calendar import c | |
from typing import List | |
# given students heights, find number of students who can see teacher standing on the right. | |
# (within context of the previous task) find an index of the student whom we could move to the back to maximize the number of students who can see the teacher standing on the right. | |
class Solution: | |
def find(self, heights: List[int]): | |
prev_height = -1 |
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
package main | |
import ( | |
"encoding/json" | |
log "github.com/sirupsen/logrus" | |
"io/ioutil" | |
"net" | |
"flag" | |
"net/http" | |
) |
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
package main | |
import ( | |
"fmt" | |
"sync" | |
"time" | |
) | |
func main() { | |
lessFriendly := throttleLoad( |
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
si () { | |
instances=$(aws ec2 describe-instances \ | |
--query 'Reservations[].Instances[].[InstanceId, Tags[?Key==`Project`]|[0].Value, Tags[?Key==`Component`]|[0].Value, State.Name]' \ | |
--filter Name=tag:Environment,Values=$@ \ | |
--output text) | |
if [ $? -ne 0 ] | |
then | |
echo failed to list instances | |
return | |
fi |
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 collections | |
def solve_c(programs, index=0): | |
reg = collections.defaultdict(list) | |
for program in programs: | |
reg[program[index % len(program)]].append(program) | |
moves = list(reg.keys()) |
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 python | |
all_primes = [5, 7, 9, 11, 13, 16, 17] | |
# the number of test cases, the number of nights allowed per test case and the maximum number of gophers, respectively | |
T, N, M = map(int, input().split(" ")) | |
def filter(number, remainder, generator): | |
for candidate in generator: |
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 collections | |
def solve(N: int): | |
words = [input()[::-1] for _ in range(N)] # reversed | |
d = collections.defaultdict(list) | |
index = 0 | |
for word in words: | |
d[word[index]].append(word) |
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
def solution(n: int, path: str): | |
d = { | |
'S': 'E', | |
'E': 'S', | |
} | |
return "".join(map(d.get, path)) | |
for t in range(1, int(input()) + 1): | |
size = int(input()) | |
path = solution(size-1, input()) |
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
def solution(inp): | |
i, first, second = 0, 0, 0 | |
scale = 1 | |
while inp: | |
digit = inp % 10 | |
inp = inp // 10 | |
first_digit, second_digit = (2, 2) if digit == 4 else (digit, 0) | |
first += scale * first_digit |
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 heapq | |
class HeapElem: | |
def __init__(self, val: int, iter): | |
self.iter = iter | |
self.val = val | |
def __lt__(self, other): | |
return self.val < other.val |
NewerOlder