Minimum Number of Platforms Required for a Railway/Bus Station.Given arrival and departure times of all trains that reach a railway station, find the minimum number of platforms required for the railway station so that no train waits. We are given two arrays which represent arrival and departure times of trains that stop GFS. Also: We… Continue reading Greedy Algo

## Array – Java

Very basic way to use java array - You can either use array declaration or array literal (but only when you declare and affect the variable right away, array literals cannot be used for re-assigning an array).For primitive types: int[] myIntArray = new int[3]; int[] myIntArray = {1,2,3}; int[] myIntArray = new int[]{1,2,3}; For classes,… Continue reading Array – Java

## Pending

find median of sorted array Print all combinations of points that can compose a given number Print all possible sums of consecutive numbers with sum N Given an array of n integers. Find the maximum value of arr[i] mod arr[j] where arr[i] >= arr[j] and 1 <= i, j <= n Find a Fixed… Continue reading Pending

## Array – Set 1

Array - Set 2 More Array Problems - 1 , 2 General Direction For Thinking for Array Problem – 1. Brute force is the obvious one and should be instant response 2. Sorting (multiple pointers when sorting is also useful | sometimes search after sort ) 3. Hash When we are given condition like numbers are in… Continue reading Array – Set 1

## Array Set 2

Array Set 1 [SKIP] Find the element that appears once Given an array where every element occurs three times, except one element which occurs only once. Find the element that occurs once. Expected time complexity is O(n) and O(1) extra space. GFS Find a sorted subsequence of size 3 in linear time Given an array… Continue reading Array Set 2

## HyperLogLOg

## Imp Random Problem

Suppose I'm given a large dictionary in flat file with 200 million words and my function needs to check the existence of any given word in the dictionary, what's the fastest way to do it? You can't store the dictionary in the memory because you only have 1GB of memory. You can store it in… Continue reading Imp Random Problem

## Doubly Linked List

Linked List/Queue/Stack Pending - 1. circular 2. round petrol problem 3. linked list and stack and queue mixed problem 4. cracking the coding interview problem 5. InterviewBit Problem Set Make it a point to maintain a tail node in DLL and a size variable. ** Doubly Linked List **Reverse Doubly Linked List Code *** Sort… Continue reading Doubly Linked List

## Sliding window problem

List of question [Skip] Sliding Window Maximum (Maximum of all subarrays of size k) - Given an array and an integer k, find the maximum for each and every contiguous subarray of size k. Youtube. We are skipping this question as it the dequeue implementation is tough and not worth the time. It will be difficult… Continue reading Sliding window problem

## Priority Queue

http://www.geeksforgeeks.org/applications-priority-queue/ Find median in stream of numbers - MedianFinder.java