guilhebl

Philosophical writings about programming and technology

Java 8 Stream API - a new way of dealing with Collections

Java 8 Stream API Perhaps one of the most used Java API is the Collections API, Lists, HashMaps, Sets, and others are used pretty much all the time, good news is that Java 8 provides...
Read more...
25 March 2015

Find max diameter of binary tree

Problem overview The max diameter of binary tree is the largest distance between 2 nodes in the tree. Example: balanced binary tree Answer: 7 unbalanced binary tree Answer: 9 Algorithm analysis The Max diameter of...
Read more...
20 March 2015

Find first K available timeslots for N people

Problem overview You are given a function: List getTimeSlots (String friend) Assume getTimeSlots() returns available times for a friend, sorted in order, with no overlap. You want to schedule a meeting among all of your...
Read more...
19 March 2015

Knapsack

Problem overview Given an array of n integers, A = { a1, a2, a3, …, an }, and another integer k representing the expected sum. Select zero or more numbers from A such that the...
Read more...
19 March 2015

Find lowest possible sequential number from numeric string while deleting k elements

Problem overview Given a numeric string S (i.e "6205123" ) of size N containing only digits and a number K where 1 <= K <= N, find the minimum number of possible from deleting K...
Read more...
19 March 2015

How many characters should be removed to Make it an Anagram

Problem overview Given two strings (of same or different length) design an algorithm to find the minimum number of character deletions required to make two strings anagrams. Any character can be deleted from any of...
Read more...
11 March 2015

Longest subset with difference 0 or 1

Problem overview Given a list of integers, e.g.: {9,5,2,1,1,0,1,4,6,7} Write an algorithm to find the longest subset in which the difference between the minimum and maximum numbers is 0 or 1. The subset can have...
Read more...
10 March 2015

Linux Kernel overview and useful links

Linux Kernel overview Useful Links Kernel archives page. Kernel source on github.
Read more...
03 March 2015