Skip to content

Instantly share code, notes, and snippets.

@wmichelin
wmichelin / MinimalTree.php
Created September 17, 2017 21:02
BST creation
<?php declare(strict_types=1);
/**
* Minimal Tree: Given a sorted (increasing order) array with unique integer elements, write an
* algorithm to create a binary search tree with minimal height.
*/
class BinaryTreeNode
{
private $value;
private $left;
@wmichelin
wmichelin / robot_in_grid.php
Last active June 20, 2017 04:38
Robot in grid
<?php
/**
* Imagine a robot sitting on the upper left corner of grid with r rows and c columns.
* The robot can only move in two directions, right and down,
* but certain cells are "off limits" such that the robot cannot step on them.
* Design an algorithm to find a path for the robot from the top left to the bottom right.
*/
/**
@wmichelin
wmichelin / problem.png
Last active June 19, 2017 01:19
calculate permutations
problem.png
@wmichelin
wmichelin / problem.png
Last active June 18, 2017 02:31
sort_anagrams
problem.png
@wmichelin
wmichelin / linked_list.php
Created June 9, 2017 07:25
Stupid linked list problems
<?php
class Node
{
/**
* @var Node
*/
private $next = null;
/**
@wmichelin
wmichelin / is_permutation.php
Last active June 9, 2017 07:17
Stupid programming questions
<?php
function isPermutation($stringA, $stringB)
{
$aMap = [];
$bMap = [];
foreach (str_split($stringA) as $char) {
isset($aMap[$char]) ? $aMap[$char]++ : $aMap[$char] = 1;
}

Keybase proof

I hereby claim:

  • I am wmichelin on github.
  • I am wmichelin (https://keybase.io/wmichelin) on keybase.
  • I have a public key whose fingerprint is ACAE A294 C4D6 6491 02D9 66CE D504 067E F262 65B3

To claim this, I am signing this object: