Featured Article

C++ Magicians – STL Algorithms

For all those who aspire to excel in competitive programming, only having a knowledge about containers of STL is of less use till one is not aware what all STL has to offer. STL has an ocean of algorithms, some of the most used algorithms on vectors and most useful one’s in Competitive Programming are… Read More »

Featured Article

A* Search Algorithm

Motivation To approximate the shortest path in real-life situations, like- in maps, games where there can be many hindrances. We can consider a 2D Grid having several obstacles and we start from a source cell (coloured green below) to reach towards a goal cell (coloured red below) What is A* Search Algorithm? A* Search algorithm… Read More »

Implementation of Minesweeper Game

Remember the old Minesweeper ? We play on a square board and we have to click on the board on the cells which do not have a mine. And obviously we don’t know where mines are. If a cell where a mine is present is clicked then we lose, else we are still in the… Read More »

Print shortest path to print a string on screen

Given a screen containing alphabets from A-Z, we can go from one character to another characters using a remote. The remote contains left, right, top and bottom keys. Remote : Find shortest possible path to type all characters of given string using the remote. Initial position is top left and all characters of input string… Read More »

Longest Common Prefix | Set 5 (Using Trie)

Given a set of strings, find the longest common prefix. Input : {“geeksforgeeks”, “geeks”, “geek”, “geezer”} Output : “gee” Input : {“apple”, “ape”, “april”} Output : “ap” Previous Approaches : Word by Word Matching , Character by Character Matching, Divide and Conquer , Binary Search. In this article, an approach using Trie date structure is… Read More »

Longest Common Prefix | Set 4 (Binary Search)

Given a set of strings, find the longest common prefix. Input : {“geeksforgeeks”, “geeks”, “geek”, “geezer”} Output : “gee” Input : {“apple”, “ape”, “april”} Output : “ap” Previous Approaches – Word by Word Matching , Character by Character Matching, Divide and Conquer In this article, an approach using Binary Search is discussed. Steps: Find the… Read More »

Lower case to upper case – An interesting fact

Problem: Given a string containing only lowercase letters, generate a string with the same letters, but in uppercase. Input : GeeksForGeeks Output : GEEKSFORGEEKS The first method that comes to our mind is Output : GEEKSFORGEEKS A more interesting solution, on the other hand, would be: Output : GEEKSFORGEEKS Explanation: The ASCII table is constructed… Read More »

D E Shaw Interview Experience | Set 17 (Arcesium for 1 Yr & 8 Months Experienced)

1st Round (2 hr) 1) About current work 2) OS -> factors to consider while designing an Operating system. followed by discussions on virtual memory, paging, thrashing, memory management. 3) Java -> Singleton pattern code, some basic questions,one problem related to constructor chaining. 4) Problem related to find suitable Data Structure for some problem ->… Read More »

Clearing The Input Buffer In C/C++

What is buffer? Temporary storage area is called buffer. All standard input and output devices contain input and output buffer. In standard C/C++, streams are buffered, for example in case of standard input,when we press the key on keyboard,it isn’t send to your program, rather it is buffered by operating system till the time is… Read More »

Longest Common Prefix | Set 3 (Divide and Conquer)

Given a set of strings, find the longest common prefix. Input : {“geeksforgeeks”, “geeks”, “geek”, “geezer”} Output : “gee” Input : {“apple”, “ape”, “april”} Output : “ap” We have discussed word by word matching and character by character matching algorithms. In this algorithm, a divide and conquer approach is discussed. We first divide the arrays… Read More »

Repeated subsequence of length 2 or more

Given a string, find if there is any subsequence of length 2 or more that repeats itself such that the two subsequence don’t have same character at same position, i.e., any 0’th or 1st character in the two subsequences shouldn’t have the same index in the original string. Example. Input: ABCABD Output: Repeated Subsequence Exists… Read More »

Longest Common Prefix | Set 2 (Character by Character Matching)

Given a set of strings, find the longest common prefix. Input : {“geeksforgeeks”, “geeks”, “geek”, “geezer”} Output : “gee” Input : {“apple”, “ape”, “april”} Output : “ap” We have discussed word by word matching algorithm in previous post. In this algorithm, instead of going through the strings one by one, we will go through the… Read More »

Longest Common Prefix | Set 1 (Word by Word Matching)

Given a set of strings, find the longest common prefix. Input : {“geeksforgeeks”, “geeks”, “geek”, “geezer”} Output : “gee” Input : {“apple”, “ape”, “april”} Output : “ap” We start with an example. Suppose there are two strings- “geeksforgeeks” and “geeks”. What is the longest common prefix in both of them? It is “geeks”. Now let… Read More »