Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [interview-questions]

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

Filter by
Sorted by
Tagged with
7
votes
2answers
434 views

Codility: An activity selection problem about scheduling two enemies to watch movies at a festival

I don't remember the exact wording of the question, but it is clearly an activity selection problem, which is [...] notable in that using a greedy algorithm to find a solution will always result in ...
2
votes
0answers
466 views

Leetcode 10: Regular Expression Matching

Problem statement Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching ...
1
vote
2answers
78 views

Given a list containing dates and the amount spent on each date, display the total amount spent per month

I had an interview yesterday where I was asked to write a function that would take in a list containing a date and the amount of money spent on that date, and to output the total amount spent per ...
2
votes
0answers
244 views

Learn trie through Leetcode 212

Problem statement: Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adjacent cell, where "...
1
vote
1answer
687 views

Display Object as a node tree in HTML with clickable trace back to root node

I was given the following code and instructions for a technical test for a potential technical role I had applied for: ...
3
votes
1answer
785 views

Four sum algorithm mock interview practice

Problem statement The algorithm is similar to Leetcode 18 4Sum, the algorithm is to find one unique quadruplets compared to Leetcode 18 finding all unique quadruplets. Given an array S of n ...
12
votes
10answers
6k views

Tests for palindromes in C and C++

A question I've been asked on interactive phone screens is to code a test to determine whether a string is a palindrome or not. I am providing two examples here: one in C and one in C++. They both ...
1
vote
1answer
714 views

performance of modulus operator vs if statement [closed]

The following code if (i >= N) i = 0; has been corrected to: i %= N; for performance reasons. Does it makes sense? ...
3
votes
1answer
1k views

Counting unique words, numbers, or phrases

I was given the below scenario to write a java program by a Software company. I did my best and was well tested as well. They came back rejecting my application without giving any review comments. I ...
6
votes
5answers
4k views

Simple online auction system in Java

I recently applied for a Java developer position and I was asked to completed a coding task. After review of the coding task, the company said they do not want to take me forward to interview. They ...
5
votes
1answer
3k views

Sudoku solver recursive solution with clear structure

Problem statement Similar to Leetcode 37 Sudoku solver, the algorithm is to determine if the sudoku board can be filled with ‘1’,‘2’,…,‘9’. A sudoku board is represented as a two-dimensional 9x9 ...
4
votes
1answer
2k views

Create an implementation of Deque (double-ended queue) with linked list nodes

I encountered this question as I am preparing for my code interview. Using Python, create an implementation of Deque (double-ended queue) with linked list nodes that has attributes of both front ...
5
votes
2answers
14k views

Elevator design (interview)

I believe interviews (~1 hour) commonly ask to code an elevator system, so this is my attempt. I made some requirements/assumptions: support one or more elevators accept pickup requests (think of up/...
5
votes
1answer
978 views

Base conversion: decode and encode base to integer

I encountered this question as I am preparing for my code interview. I was implementing a base function that can decode and encode any bases from base 2 to base 36. I think my ...
2
votes
1answer
637 views

Stack using linked List

I have this problem with my interview. I was asked to implement a stack using a linked list. Gist ...
3
votes
1answer
1k views

Palindrome implementations - iterative and recursive

I got asked this palindrome question when the interviewer wants to make sure that my palindrome can check if "Taco! Cat!" is a palindrome. In this example, my palindromes implementation needs to ...
3
votes
1answer
137 views

Simulated race among three robots making random steps

At a job interview, I was asked to code the following algorithm: Given are three robots which advance across a 1km lane at a different pace respectively. Each pace made by a robot is of a random ...
10
votes
2answers
229 views

Python implementation of find_all_indexes

I got asked this question before in an interview. For example, find_all_indexes('ababc', 'abc') returns 2. This Python function ...
2
votes
2answers
374 views

Count of Smaller Numbers After Self

This is a LeetCode.com problem. https://leetcode.com/problems/count-of-smaller-numbers-after-self/description/ You are given an integer array nums and you have to return a new counts array. The ...
5
votes
3answers
260 views

A program to tell you if there are 2 numbers in an array that add to a given sum

there is a video on life at google about what an interview would be like and so i watched it and decided to go along and come up with a solution to the problem myself and i found it really easy this ...
10
votes
2answers
3k views

xml is XML is xml is XML

I had to write some code for an interview, to print out the name attribute of each node. I started off going in the wrong direction, so I didn't get to finish. I wanted to finish writing the code, so ...
12
votes
2answers
6k views

LRU cache implementation

I have implemented an LRU cache, the question is taken from: leetcode: 146. LRU Cache Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following ...
4
votes
3answers
960 views

Expense Sharing Calculation

The following is my solution to the problem presented on this CodeReview post: Friends A, B, C, D go for a trip. They spend on various expenses. Cost of the expense is shared. Example : ...
5
votes
4answers
3k views

Expense-sharing calculation

Friends A, B, C, D go for a trip. They spend on various expenses. Cost of the expense is shared. Example : A spends 100 for breakfast for A, B, C and D D spends 500 for cab for B and C B spends 300 ...
3
votes
3answers
1k views

Vending machine change function

Write a function that takes an amount of money M, a price P and returns the change given in the smallest number of coins. The ...
2
votes
1answer
72 views

Minesweeper field marking

I just did an interview where the last challenge was to write a function that reads a minesweeper matrix from a file and marks how many bombs there are around each cell. I had 20 min and had a ...
1
vote
1answer
98 views

News-reading application using the Observer pattern

I have found this question online from an Amazon interview: Design a kind of Kindle Fire application where we can subscribe to a news channel and read the news from all publishers as a digital ...
6
votes
3answers
2k views

OOP Chess design job interview practice

please comment on game flow, Solid principle and OOP concepts. ...
5
votes
2answers
2k views

Find the smallest substring that contains some given subset of characters

Problem statement: Given a string as a "source" string, find the smallest substring of source such that it contains all characters in "search" string (which contains distinct characters). For ...
7
votes
1answer
547 views

Shortest path to transform one word into another

I submitted the following code for a job application, and was rejected. They gave no feedback. Would appreciate any comments on the approach I took, and coding style. This is the question: Given ...
2
votes
1answer
3k views

Insurance premium calculator exercise

I attempted a coding exercise during an interview, defined & implemented here (readme for problem): https://gitlab.com/vineet_rc/health-insurance-premium-quote-generator-2 It was initially a ...
7
votes
3answers
2k views

Object-oriented Bank class

I am quite new to programming and was given an assignment in a job recruitment(now finished) to program a simple Bank class and other relevant classes based on this interface: ...
4
votes
2answers
101 views

Find the kth element which is either divisible by l or r or both

This was asked to me in one of interview, so can someone please have a look is my code efficient or we can further improve it. Example ...
3
votes
2answers
2k views

Designing a call center in object oriented way

Description: Below is one of the interview practice question. I think questions like these are to test the candidate's capability to write object oriented code. I being a candidate right now don't ...
4
votes
2answers
637 views

Implementation about animal shelter that allows only cats and dogs

Well known problem: An animal shelter, which holds only dogs and cats, operates on a strictly "first in, first out" basis. People must adopt either the oldest (based on arrival time) of all ...
4
votes
3answers
137 views

Implementation of a simple stack with min method

The problem statement: Implement a stack which has push and pop method and also min method whereas min method has \$O(1)\$ complexity. From an interview standpoint, what mistakes would you point ...
5
votes
1answer
989 views

LRU Cache Implementation with HashTable and LinkedList

Problem Statement: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the value (will always be ...
-2
votes
3answers
133 views

Interview project to redesign a website for a property

I'm applying for a UI/UX position at a company that makes software for landlords, apartments, property managers, etc. After the interview the hiring manager gave me a project to work on. These are the ...
11
votes
5answers
18k views

Checking if a number is power of 2 or not

This is my solution in Java and I need your opinion: ...
1
vote
2answers
4k views

Finding occurrence of a given character in a String?

I came up with this simple solution: ...
3
votes
6answers
2k views

Blackjack game interview task

As part of a recent interview, I was assigned to write a small BlackJack program. After submitting the solution, I received an answer that "the solution was functionally OK, but was way below their ...
5
votes
2answers
1k views

Bounded Queue with multiple consumers and multiple producers

It was an interview question: Should implement a class - BlockingQueue with those constraints: 2 Methods - Adding an item and Take an item from the queue. The class should support multiple consumers ...
6
votes
1answer
1k views

Implementing a dictionary and thesaurus in Python

Write code that functions as both a dictionary and a thesaurus. Supported operations: Add a word and its definition to the dictionary Add a synonym to a word in the dictionary Look up ...
1
vote
2answers
228 views

Checking if a number is Armstrong number or not

here is another basic interview question that I had: Armstrong Numbers ...
0
votes
1answer
183 views

Checking if a number is palindrome or not in Java

Got this question in a technical interview and here is my solution: ...
2
votes
3answers
284 views

Generate die rolls using coin flips

Problem I've seen this basic interview question in a couple of places, but never implemented it. Create an algorithm to output a fair die roll (values between 1 ...
0
votes
1answer
60 views

Replacing all the 'u' with specific character that is given by the user

I got this question for a Junior Software Developer interview. And came up with this solution in Java: ...
2
votes
1answer
788 views

Regular Expression Matching: Recursive and DP-based implementation

Problem Statement: Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching ...
3
votes
4answers
467 views

Finding anagrams in Java (space-optimised)

I've lately been asked in a job interview to program a solution for the well known anagrams problem: given two strings s1 and s2,...
5
votes
2answers
306 views

Test whether the edit-distance of two strings is at most 1

There are three types of edits that can be performed on strings: insert a character, remove a character, or replace a character. EXAMPLES: ...