Skip to content

Instantly share code, notes, and snippets.


Selim Ozturk selimslab

View GitHub Profile

When you first solve a problem, you come up with something very complex, and most people stop there. If you keep living with the problem you arrive at very elegant and simple solutions. - Steve Jobs

these 2 solutions for the same problem reminds me this quote

View nodeSummary.js
// net
var http = require('http');
var url = require('url');
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/html' });
var q = url.parse(req.url, true).query;
var txt = q.year + " " + q.month;
selimslab / LoginUtil.kt
Created May 31, 2020
native Android login, in Kotlin
View LoginUtil.kt
package com.example.ozturkse.awesomelogin
import android.content.Context
class LoginUtil {
private val EMAIL = "email_shared_pref"
private val PASSWORD = "password_shared_pref"
selimslab /
Last active May 27, 2020
a simple interpreter in python
Here be dragons
This is a basic interpreter
a computer program is just text. Compilers and interpreters translate this text for the machine
let's say our program is 2 * 7 + 3
1. First step is lexical analysis, a fancy term for tokenizing
def minWindow(self,s, t):
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).
Output: "BANC"
1. Use two pointers: start and end to represent a window.
2. Move end to find a valid window.
3. When a valid window is found, move start to find a smaller window.
View map.js
function map(func, array) {
var result = [];
forEach(array, function (element) {
return result;
show(map(Math.round, [0.01, 2, 9.89, Math.PI]));
View findUnsortedSubarray.js
const findUnsortedSubarray = nums =>
.sort((a, b) => a - b)
.reduce((acc, curr, idx) => acc + (curr === nums[idx] ? ' ' : 'x'), '')
"""Design an algorithm to serialize and deserialize a binary tree. """
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Codec:
class Trie:
""" or prefix tree """
def __init__(self):
a child of a Trie is a Trie
self.trie = {}
def insert(self, word: str) -> None:

You are a professional robber planning to rob houses along a street.

Each house has a certain amount of money stashed.

Meanwhile, adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.

q1: max robbery ?

q2: what if houses form a circle so the first and last are neighbors ?

You can’t perform that action at this time.