# Archive for November 2016

Problem statement Given sticks of lengths , use of the sticks to construct a non-degenerate triangle with the maximum possible perimeter. Then print the lengths of its sides as space-separated integers in non-decreasing order. If there are several valid triangles having the maximum perimeter: Choose the one with the longest . . . Read more

Problem statement Given two strings and of equal length, what’s the longest string () that can be constructed such that it is a child of both? A string is said to be a child of a string if can be formed by deleting or more characters from . For example, . . . Read more

This is a rather short post. in which I explain how to we can implement a fast pow function to raise a number to the power of . A rather naive approach would be to do the following: int pow(int x, int n){ int result = 1; while (n > . . . Read more

Problem statement You are situated in an dimensional grid at position . The dimensions of the grid are In one step, you can walk one step ahead or behind in any one of the dimensions. (So there are always possible different moves). In how many ways can you take steps . . . Read more

Problem statement The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, … 1 is read off as one 1 or 11. 11 is read off as two 1s or 21. 21 is read off as one 2, then one 1 or 1211. Given . . . Read more

Full code https://github.com/lucaslouca/parallax-scrolling

The Boyer–Moore string search algorithm is an efficient string searching algorithm that is the standard benchmark for practical string search literature. For instance, GNU grep uses the Boyer-Moore algorithm. For a full explanation of the algorithm please refer to Wikipedia.

The Aho–Corasick algorithm is a string searching algorithm invented by Alfred V. Aho and Margaret J. Corasick. For a full explanation of the algorithm please refer to Wikipedia.

The following code reads a CSV file and converts it to List<Map<String, String>> in Java. Each row is represented by a Map<String, String> entry in the resulting List. Map<String, String> maps column name (header value) to value.

Problem statement Given a collection of intervals, merge all overlapping intervals. Sample Input [1,3],[2,6],[8,10],[15,18] Output [1,6],[8,10],[15,18] Solution Concept We sort the intervals by decreasing order of start times. That way we can quickly check if intervals overlap or not by comparing start time of previous interval with end time of . . . Read more