Skip to content

Instantly share code, notes, and snippets.

@jeb2239
jeb2239 / main.cc
Created October 31, 2020 20:00
read binary file in c
#include <stdio.h>
/* random record description - could be anything */
struct rec
{
int x,y,z;
};
/* writes and then reads 10 arbitrary records
from the file "junk". */
@jeb2239
jeb2239 / lesson.py
Last active November 4, 2020 16:24
lesson
‎‎​
@jeb2239
jeb2239 / ac.py
Created November 4, 2020 19:56
mehdi
#!/bin/python3
import math
import os
import random
import re
import sys
import functools
#
# Complete the 'passwordCracker' function below.
class Solution:
# you need startIdx for this prob
def countVowelStrings(self, n: int) -> int:
vowels = ['a','e','i','o','u']
result=[]
def cvs(curr,n,startIdx):
if n==1:
result.append(curr)
return 1
UP=3
LEFT=2
DOWN=1
RIGHT=0
DIRS = [(0,1),(1,0),(0,-1),(-1,0)]
def spiral_copy(inputMatrix):
@jeb2239
jeb2239 / todos---remind.txt
Last active November 12, 2020 15:32
todos
hello
@jeb2239
jeb2239 / code.py
Last active November 12, 2020 15:38
medhi/code.py
‎‎​
@jeb2239
jeb2239 / binarysearch---rodCutting.py
Last active November 13, 2020 15:53
codeProblems
# https://binarysearch.com/problems/Rod-Cutting
class Solution:
def solve(self, prices, n):
memoRec=[-1]*(n+1)
def rodCutRec(rodLeft,prices):
if memoRec[rodLeft]!=-1:
return memoRec[rodLeft]
import heapq as hq
import sys
import math
from typing import NamedTuple
class Entry(NamedTuple):
cost:int
node:int
class Solution:
@jeb2239
jeb2239 / main.py
Created November 30, 2020 18:13
1361
#buggy code took 20 minutes
class Solution:
def validateBinaryTreeNodes(
self, n: int, leftChild: List[int], rightChild: List[int]
) -> bool:
nparent = [0] * n
for i in range(n):
leftv = nparent[leftChild[i]]