All Hard Articles

## Amazon Interview | Set 14 4.5

Team : Transportation Location :Hyderabad Round 1 (Online Test) Q1. Find the kth largest value in a BST Q2. Swap the alternate nodes in a singly linked… Read More »

## Directi Interview | Set 1 4.4

Written Round: 1) Given a binary tree, such that each node contains a number. Find the maximum possible sum in going from one leaf node… Read More »

## Optimal Binary Search Tree | DP-24 4

Given a sorted array keys[0.. n-1] of search keys and an array freq[0.. n-1] of frequency counts, where freq[i] is the number of searches to… Read More »

## Program to find amount of water in a given glass 4.2

There are some glasses with equal capacity as 1 litre. The glasses are kept as follows: 1 2 3 4 5 6 7 8 9… Read More »

## Amazon Interview | Set 12 4.6

I am very thankful to geeksforgeeks team for such a great site. I got offer from Amazon. Written Test It was online test on interviewstreet.… Read More »

## Closest Pair of Points using Divide and Conquer algorithm 4.3

We are given an array of n points in the plane, and the problem is to find out the closest pair of points in the… Read More »

## Construction of Longest Increasing Subsequence (N log N) 4.4

In my previous post, I have explained about longest increasing sub-sequence (LIS) problem in detail. However, the post only covered code related to querying size of… Read More »

## Prim’s MST for Adjacency List Representation | Greedy Algo-6 4.4

We recommend to read following two posts as a prerequisite of this post. 1. Greedy Algorithms | Set 5 (Prim’s Minimum Spanning Tree (MST)) 2.… Read More »

## Amazon Interview | Set 10 4

Recently I got interviewed at Amazon Hyderabad. I just wanted to share my experience. Hope someone gets little help from this. 1. Telephonic a. In… Read More »

## Select a random number from stream, with O(1) space 4.1

Given a stream of numbers, generate a random number from the stream. You are allowed to use only O(1) space and the input is in… Read More »

## Branch prediction macros in GCC 4.3

One of the most used optimization techniques in the Linux kernel is ” __builtin_expect”. When working with conditional code (if-else statements), we often know which… Read More »

## Given a sequence of words, print all anagrams together | Set 2 4.1

Given an array of words, print all anagrams together. For example, if the given array is {“cat”, “dog”, “tac”, “god”, “act”}, then output may be… Read More »

## Inplace (Fixed space) M x N size matrix transpose | Updated 4.3

About four months of gap (missing GFG), a new post. Given an M x N matrix, transpose the matrix without auxiliary memory.It is easy to… Read More »

## An in-place algorithm for String Transformation 4.6

Given a string, move all even positioned elements to end of string. While moving elements, keep the relative order of all even positioned and odd… Read More »

## Construct BST from given preorder traversal | Set 2 4.1

Given preorder traversal of a binary search tree, construct the BST. For example, if the given traversal is {10, 5, 1, 7, 40, 50}, then… Read More »

## Print all permutations in sorted (lexicographic) order 4.2

Given a string, print all permutations of it in sorted order. For example, if the input string is “ABC”, then output should be “ABC, ACB,… Read More »

## Construct Full Binary Tree from given preorder and postorder traversals 4.1

Given two arrays that represent preorder and postorder traversals of a full binary tree, construct the binary tree. A Full Binary Tree is a binary… Read More »

## Adobe Interview | Set 2 4.3

I have recently been through the recruitment process of ADOBE. I didn’t get through (I got the reply today), but I sincerely hope that my… Read More »

## Find the element that appears once 4.2

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… Read More »