Skip to content

Instantly share code, notes, and snippets.

View folksilva's full-sized avatar

Luiz Fernando da Silva folksilva

View GitHub Profile
@folksilva
folksilva / problem3.py
Created January 4, 2018 20:19
Daily Coding Problem: Problem #3
"""
This problem was asked by Google.
Given the root to a binary tree, implement serialize(root), which serializes the tree into a string, and deserialize(s), which deserializes the string back into the tree.
https://dailycodingproblem.com/
"""
class Node:
def __init__(self, value):
@folksilva
folksilva / problem4.py
Created January 5, 2018 17:22
Daily Coding Problem: Problem #4
"""
This problem was asked by Stripe.
Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.
For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3.
You can modify the input array in-place.
https://dailycodingproblem.com/
@folksilva
folksilva / problem5.py
Last active June 19, 2018 21:29
Daily Coding Problem: Problem #5
"""
This problem was asked by Jane Street.
cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first and last element of that pair. For example, car(cons(3, 4)) returns 3, and cdr(cons(3, 4)) returns 4.
Given this implementation of cons:
def cons(a, b):
return lambda f : f(a, b)
Implement car and cdr.
@folksilva
folksilva / problem21.py
Last active November 27, 2020 18:24
Daily Coding Problem: Problem #21
"""
This problem was asked by Snapchat.
Given an array of time intervals (start, end) for classroom lectures (possibly overlapping), find the minimum number of rooms required.
For example, given [(30, 75), (0, 50), (60, 150)], you should return 2.
https://dailycodingproblem.com/
"""
import itertools
@folksilva
folksilva / problem22.py
Created January 23, 2018 20:02
Daily Coding Problem: Problem #22
"""
This problem was asked by Microsoft.
Given a dictionary of words and a string made up of those words (no spaces), return the original sentence in a list. If there is more than one possible reconstruction, return any of them. If there is no possible reconstruction, then return null.
For example, given the set of words 'quick', 'brown', 'the', 'fox', and the string "thequickbrownfox", you should return ['the', 'quick', 'brown', 'fox'].
Given the set of words 'bed', 'bath', 'bedbath', 'and', 'beyond', and the string "bedbathandbeyond", return either ['bed', 'bath', 'and', 'beyond] or ['bedbath', 'and', 'beyond'].
https://dailycodingproblem.com/
@folksilva
folksilva / problem23.py
Created January 24, 2018 20:05
Daily Coding Problem: Problem #23
"""
This problem was asked by Google.
You are given an M by N matrix consisting of booleans that represents a board. Each True boolean represents a wall. Each False boolean represents a tile you can walk on.
Given this matrix, a start coordinate, and an end coordinate, return the minimum number of steps required to reach the end coordinate from the start. If there is no possible path, then return null. You can move up, left, down, and right. You cannot move through walls. You cannot wrap around the edges of the board.
For example, given the following board:
[[f, f, f, f],
@folksilva
folksilva / main.js
Created March 26, 2019 21:35
Iteração da página web remota com o Electron
// main.js - Arquivo principal do electron
// executado via npm start
const { app, BrowserWindow } = require('electron')
function createWindow () {
let win = new BrowserWindow({width: 800, height: 600})
win.loadURL("http://localhost:8000/teste.html")
}