Find the skyline of a group of buildings
The Coding Interview Blog
by admin
3y ago
© Parineeth M R Question 61. Find the skyline of a group of buildings The skyline problem is pretty popular in coding interviews. Here we take an in depth look at how to solve the problem. Consider the diagram below where there are 4 buildings: B1 (height = 20), B2 (height = 30), B3 (height ..read more
Visit website
What could possibly be wrong with the C declaration char x;?
The Coding Interview Blog
by admin
3y ago
© Parineeth M R Consider the code below: We expect that the output printed is -1. However this is not true in all the platforms. When we declare a variable as int x, we are sure that the variable x is a signed integer even if we don’t specify the “signed” keyword in the declaration ..read more
Visit website
Links to code in github
The Coding Interview Blog
by admin
3y ago
The 3rd edition of The Big Book of Coding Interviews is now ready. The links to the code for the book are C and C++: https://github.com/parineeth/tbboci-3rd-edition-c-and-cpp Java: https://github.com/parineeth/tbboci-3rd-edition-java Python: https://github.com/parineeth/tbboci-3rd-edition-python ..read more
Visit website
Cycle in a directed graph
The Coding Interview Blog
by admin
3y ago
© Parineeth M R Question 60. Find if a directed graph has a cycle Suppose we are given an undirected graph and asked to find a cycle in it, then all we need to do is the following 1. Initialize all nodes in the graph as unvisited. 2. Pick a node that has not been ..read more
Visit website
Find the number of islands in a matrix
The Coding Interview Blog
by admin
3y ago
© Parineeth M R Question 59. A 2-dimensional matrix consists of 0’s and 1’s. An island is defined as a contiguous occurrence of 1’s that are adjacent to each other. Find the number of islands in the matrix If there are two adjacent cells (left-right neighbors, top-down neighbors, diagonally adjacent neighbors) with a value 1 ..read more
Visit website
Sudoku solver
The Coding Interview Blog
by admin
3y ago
© Parineeth M R Question 58. Implement a Sudoku solver The Sudoku grid is square of size 9 * 9. The rules of Sudoku are as follows: 1. Each cell contains a number from 1 to 9 2. A number should not be repeated in the same row or the same column 3. The grid ..read more
Visit website
Snake and ladders game
The Coding Interview Blog
by admin
3y ago
© Parineeth M R Question 57. Find the least number of dice throws needed to complete the snake and ladders game To find the least number of dice throws, we use the following dynamic programming technique: 1. Initialize the least number of throws needed to reach the positions 1-6 on the board as 1 since ..read more
Visit website
Longest increasing subsequence
The Coding Interview Blog
by admin
3y ago
© Parineeth M R Question 56. Find the longest increasing subsequence in an unsorted array of numbers Consider the sequence A = {30, 40, 20, 70, 10}. The longest increasing subsequence is {30, 40, 70}. Here we are considering a strictly increasing longest subsequence and so a number can be present only once in the ..read more
Visit website
Coin change problem
The Coding Interview Blog
by admin
3y ago
© Parineeth M R Question 55. Given a set of coin denominations, find the change for a given amount using the least number of coins. For instance, suppose the coin denominations are 4¢, 5¢ and 7¢, then to get 13¢ using the least number of coins, we need to pick two 4¢ coins and one ..read more
Visit website
Maximum Continuous Sum
The Coding Interview Blog
by admin
3y ago
© Parineeth M R Question 54. Find the maximum continuous sum in an array An array can have positive and negative elements in it. We have to find a subset of contiguous elements in the array whose sum is the maximum. Let the maximum continuous sum be represented as MCS In the brute force approach ..read more
Visit website

Follow The Coding Interview Blog on FeedSpot

Continue with Google
Continue with Apple
OR