The Stack Overflow podcast is back! Listen to an interview with our new CEO.

# Questions tagged [interview-questions]

This tag is for questions that came up in an interview.

830 questions
Filter by
Sorted by
Tagged with
1k views

### Print concentric rectangular patterns

I am solving interview questions from here. Problem : Print concentric rectangular pattern in a 2d matrix. The outermost rectangle is formed by A, then the next outermost is formed by A-1 and so on....
1k views

### Reverse Polish Notation calculator with unit tests

I had an interview with a global company yesterday. They had given me a programming assignment. I shared my screen and I must have finished the task in 1.5 hours. Task was programming Reverse Polish ...
458 views

### Calculate median of a matrix

I am solving interview questions from here. Problem : Given a N cross M matrix in which each row is sorted, find the overall median of the matrix. Assume N*M is odd. Note: No extra memory is ...
323 views

### Consume etherscan.io API, store in DB, serve from web app

I didn't make it to the next stage in this interview process, because another applicant did better than me, which wasn't surprising given that this was my first foray into Node.js. I'd like some tips ...
607 views

### Robot on a Grid: Find a path between two corners with forbidden cells on the road

Problem statement The problem is defined in the book as following: 8.2 Robot in a Grid Imagine a robot sitting on the upper left corner of grid with r rows and <...
13k views

### Get all combinations of selecting k elements from an n-sized array

Was asked this today in an interview. Didn't see it before, and spent quite a lot of time getting it to work (tricky with all the recursion). The goal was to find all possible combinations of ...
3k views

### Find maximum gap between elements of an array

I am solving interview questions from here. Problem : Given an array A of integers, find the maximum of j - i subjected to the constraint of A[i] <= A[j]. Example : A = [3 5 4 2] Output :...
764 views

### Find currency exchange rates

Description: Design a service to fetch exchange rate from a remote resource and then calculate the exchange rate for each currency pair. The remote resource contains the exchange rates of ...
155 views

### Find the longest length of sequence of 1-bits achievable by flipping a single bit from 0 to 1 in a number

Problem Statement The problem is defined in the book as following: 5.3 You have an integer and you can flip exactly one bit from 0 to ...
186 views

### Convert csv to switch commands Python

The script should be a single python file that takes an excel file (or csv). Each row represents one switch. For each switch, there will be one or more interfaces. The objective is to output a ...
650 views

### Weighted Probability in Go

I was recently tasked a programming assignment with a prospective company, unfortunately I didn't pass the assignment and didn't receive any feedback on what I could have done better. I would ...
392 views

### Number of Paths (BackTracking) in Java

Illustration You're testing a new driverless car that is located at the Southwest (bottom-left) corner of an n×n grid. The car is supposed to get to the opposite, Northeast (top-right), corner ...
930 views

### Award Budget Cuts implementation in Java

PRAMP Award Budget Cuts The awards committee of your alma mater (i.e. your college/university) asked for your assistance with a budget allocation problem they’re facing. Originally, the committee ...
187 views

### Multiple stacks implemented via a linked lists on top of single fixed-size array

Problem Statement Originally, the problem is defined in the book as following: Describe how you could use a single array to implement three stacks. — Cracking the Coding Interview (6th edition) ...
2k views

### Program to shorten URL and decode it back to get original URL

TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it returns a short URL. Design the encode and ...
755 views

### Counting ambiguous Morse Code encodings, with and without Java Streams

Unique Morse Code Words International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a" maps to ...
390 views

### Pancake sort inteview using java

Given an array of integers arr: Write a function flip(arr, k) that reverses the order of the first k elements in the array <...
1k views

### Equation Evaluator

I am currently applying to many Software Engineer positions, and have been asked to complete several coding challenges. The most recent was an equation evaluator, written in C++, that was supposed to ...
60 views

### Code improvements for React App

This was my code challenge for a Junior JavaScript Developer position. The app is mostly running error-free, but I was rejected for the role, so I assume there were major issues with my code and have ...
92 views

### Let us schedule a meeting

Description: Write a method mergeMeetings() that takes a list of multiple meeting time ranges and returns a list of condensed ranges. The integers represent the number of 30-minute blocks past 9:...
510 views

### Jumps of a pawn - Java interview [closed]

I have just attended a code test of some code testing site, and I think one question seems easy but I didn't get a high correctness, so if anyone can review this code snippet, I would appreciate it. ...
652 views

### Array partition 1 to group the array into pairs and make sum of minimum of pairs as maximum

Challenge from LeetCode: Array Partition I Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(...
3k views

### Pancake sort interview with Python

I got asked this question during my interview. You can find information about this question here. Pancake Sort Given an array of integers arr: Write a function flip(arr, k) that reverses ...
158 views

### Find The Duplicates using binarySearch python

I got this interview question from Pramp. You can find it online through their website: https://www.pramp.com/challenge/15oxrQx6LjtQj9JK9XlA Find The Duplicates Given two sorted arrays ...
4k views

### Find the minimum number of coin change

Description: You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that ...
76 views

### How to use C to solve Two Sum correctly? [closed]

Two Sum Problem: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may ...
70 views

### OOP air conditioner model

I had a phone interview and we shared a screen to do a simple challenge. Instructions were ambiguous but I basically had to implement how an air conditioner would work in general. I wrote the ...
691 views

### C++ interview problem: finding an Island in a 2D grid

I was asked this question from an online coding interview and I have provided my solution that passes all of the test cases. I wanted to see if someone can review my code. You can find my solution ...
152 views

### Searching the Array Index & Element Equality

I was asked this question from online coding interview and I have provided my solution that passes all of the test cases. I wanted to see if someone can review my code. Array Index & Element ...
696 views

### Roman to Arabic numerals converter in Javascript

I was given some homework as a technical test by a company I wanted to work for... Which I failed to the point of not being able to even access the code review portion of the interviewing process. ...
833 views

### Rate calculation system for a code challenge

This code challenge was part of a interview process I had applied for, and from which I was discarded after this test. I'd like to hear what other people have to say, hopefully in deeper detail. The ...
1k views

### Swap Nodes in Pairs in singly linked list

Description: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only ...
438 views

### Merge intervals

Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]. GitHub ...
463 views

### Remove nth node from last position in linked list

Description: Given a linked list, remove the nth node from the end of list and return its head. Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the ...
154 views

### Maximum product of a triplet in array in linear time

Given an array of integers, find the highest product you can get from three of the integers. Input: [1, -4, 3, -6, 7, 0] Output: 168 I would love to hear from how this might be refactored/...
99 views

### Find the third largest element in the array in linear time

Find Third largest element in an array Input : arr[] = {1, 14, 2, 16, 10, 20} Output : 14 Its a simple program, but would be great to know how it can be improved for better readability or ...
332 views

### Intersection of the interval set

Recently I had an interview where it was asked: Given a list of people with their birth and end years find the year with the most number of people alive. I implemented in Java and was trying to ...
703 views

### Merge non overlapping intervals

Merge Intervals Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their ...
6k views

### Filter out non-alphabetic characters from a list of words

For coding practice / interview exercises, I'd like to know if there's an optimizaton I can make to the following, where I "clean" a given word to remove punctuation or other characters that are not ...
768 views

### Sequential execution

I made a class that I think satisfies the conditions: Actions can be added to the queue at any time by any number of clients. ...
136 views

### Reverse singly linked list

Description: Given a linked list reverse it and return the new head. Code: ...
1k views

### Move last node of the linked list to the front

Description: Given a linked list move the last node to the front. For example: 10 20 30 40 -> 40 10 20 30 Code: ...
1k views

### Maximum Difference in an Array [closed]

Maintain a minimum and max difference as we scan the input array. ...
66 views

### Dutch partition

Dutch Partition problem. Partition the given array using the pivotIndex into groups with elements smaller than the pivot, equal to pivot and larger than the pivot. ...
169 views

### Naive string compression

Description: Implement a method to perform basic compression using counts of repeated characters. If the compressed string is not smaller then return the original string. Code: ...
289 views

### Check if two strings are permutations of each other

Description: Given two strings check if those two are permutation of each other. Its expected that input string can contain ASCII characters. Code: ...
78 views

### Find GCD of two numbers without using multiplication, division or modulus operators

If either a or b is 0 return the other number. If both even return gcd of a/2 and b/2. If either a or b is even divide it by 2 and return gcd of the pair. If a less than or equal to b, return the gcd ...
482 views

### Three sum using binary search

Given an array and a value, find all the triplets in the array whose sum is equal to the given value. For example, if the given array is {12, 3, 4, 1, 6, 9} and the ...