Algorithm problem of the day

Sharing algorithm problems

Sunday, April 9, 2017

Find number of islands from a give 2D matrix of 0s and 1s

›
For a given 2D matrix of 0s and 1s, find number of islands where an island is defined as number of 1s together. For example for a 2D matrix...
Sunday, April 2, 2017

Finds unique value from a sorted array that has duplicates such as [1,1,2,2,3,3]

›
    /**      * Finds unique value from a sorted array that has duplicates such as [1,1,2,2,3,3]<br/>      * The approach is to have...

Find permutations of a string

›
import java.util.*; public class Permutation {     public static void main(String[] args) {         Permutation s = new Permutation(); ...
Sunday, February 1, 2015

Regular expression implementation for '*' and '?' wildcard characters

›
Assuming we have two string - a normal string which will be matched against a regular expression string. The idea is simple: iterate throug...

›
Sliding window implementation: Problem: Given an array and subarray size, find the max. sum from subarrays. Solution:  Naive solution i...
Friday, July 6, 2012

SOLID design principles

›
To understand what these principles are, I have kept them inline comments in the code. I will keep updating the code portions that will act...
Saturday, June 30, 2012

3SUM algorithm

›
Problem is: Given an array of integers, find subset of 3 elements of the array such that sum of those three elements is zero. Brute force...
›
Home
View web version

About Me

A
View my complete profile
Powered by Blogger.