Questions tagged [interview-questions]
This tag is for questions that came up in an interview.
952
questions
11
votes
4
answers
2k
views
Simple Key Value Database using C
I was recently doing an assignment for a job interview, which asked to create a simple key value database with 4 command line operations:
create key value: Adds a key value pair/updates an existing ...
3
votes
3
answers
192
views
Extracting records from a 2D List of strings
Recently I had an interview question about extracting records that matched certain criteria from a 2D List of strings. The premise was a CSV file was parsed into a ...
1
vote
1
answer
86
views
Simple Curry function
This is a interview practice question from BFE.dev.
Currying is a useful technique used in JavaScript applications.
Please implement a curry() function, which ...
3
votes
2
answers
92
views
text format solution
A firm gave me a small take home assignment which asks you to implement text formatter. Given some text which only contains alphanumerics and spaces (only one space between words), we should align it ...
4
votes
7
answers
262
views
Breaking a string expression in operator and operands
Requesting for a code review for a scala implementation.
Problem
Given an expression string made of numbers and operators +,-,/,* , break it in a list of Integer or ...
3
votes
2
answers
3k
views
Detecting Intersections of a Collection of Singly-Linked Lists
I was recently presented with the following problem...
You are given a collection of singly-linked lists (SLLs).
Return true if any of them share a common node (or “intersect”), or false otherwise.
...
2
votes
1
answer
99
views
Detecting timeouts in a stream of events
I'm trying to come up with a solution to this interview question:
You have a stream of RPC requests coming into a server which is being
logged. Each log entry is of the form [id, timestamp,
type ('...
4
votes
2
answers
201
views
Automating the process of determining which boxes to load on each flight for freight company
I was given a test assignment for the interview of the company and below is the code that I shared with them. I developed it using .NET 6 (Core) Console application.
Actual problem statement:
Coding ...
5
votes
1
answer
203
views
Object-oriented elevator scheduler
The elevator system has the following functions:
There is one building, and the number of elevators can be set arbitrarily.
Requests can be sent from outside the elevators, in this case the request ...
2
votes
1
answer
213
views
Pick two random cards from a standard deck
I wrote this code as a refactor of code I saw on Programiz. I thought about this refactor before going to bed and implemented it successfully in code.
...
3
votes
2
answers
152
views
Goats up hills II: revenge of the goat
This is a continuation of Goat racing up a hill (C++ hiring take-home) . This is an interview take-home challenge that has been translated to avoid compromising the company's question.
Problem ...
6
votes
4
answers
822
views
Counting the number of patterns that exist in a particular string
I am solving this problem where the function returns the number of times a pattern is found in a said string word. It could be easily solved via ...
12
votes
3
answers
4k
views
Goat racing up a hill (C++ hiring take-home)
This is an interview take-home challenge that has been translated to avoid compromising the company's question.
Problem statement
You are a goat that needs to race up a hill. Designated waypoint rocks ...
1
vote
3
answers
656
views
Grouping objects in a JavaScript array by category and counting them
I recently had a programming interview with a Silicon Valley tech company and wanted some different opinions on one of the problems they had me solve and how others might complete it. Essentially, ...
4
votes
6
answers
1k
views
Reverse string with identical spaces as in original String using Java
This is interview question
Reverse string with identical spaces as in original String using Java
For example
Original String :
best in the world and is greatest and is making sure the world goes
well
...
3
votes
1
answer
880
views
Small shopping cart application - Solid Principles and Clean Code
I've recently had a technical interview where I had to identify code smells and refactor an existing code by applying the SOLID principles and implementing unit tests.
It is a small shopping cart ...
2
votes
1
answer
51
views
Implement simplified liquibase
I attended job interview and on live codeing session was asked to implement code based on some requirements. There are quite long text description but idea that we have to accept some file system path ...
1
vote
2
answers
144
views
Why my implementation of Anagram function is redundant and might have cache issues?
Task
I was asked to write a function, which can determine (return a bool) whether 2 given strings are anagrams of each other?
That function should have the following constraints:
Upper and lowercase ...
2
votes
1
answer
217
views
Design Tic Tac Toe Interview Problem [Python 3]
Practicing objected oriented design. This time, it's designing the TicTacToe game. One difference between the real TicTacToe game is that I've made my TicTacToe game to have variable sized board.
...
4
votes
1
answer
2k
views
Design Shopping Cart System Interview Problem [Python 3]
Just practicing some objected oriented design questions. Please let me know what can be improved to be more OOD and extensible. Thank you.
Functional Requirements
Cart can hold multiple products
A ...
3
votes
0
answers
548
views
Async FIFO processing of database writes - naive implementation in .Net 6
One of the companies I was recently interviewing with gave me a following task to implement in a day or two using .Net, just to see where my coding abilities are at:
Implement a Web API that gets ...
1
vote
6
answers
193
views
Find first and last matches on a sorted list
I needed a function to find the first and last indices into a sorted list corresponding to a given value (roughly similar to C++'s equal_range()).
This is the ...
1
vote
1
answer
269
views
Finding the winner of a tic-tac-toe game in Swift
Working on the problem Find Winner on a Tic Tac Toe Game, I took several hours longer than an artificial time constraint the site had for mock interview purposes. This leads me to wonder if my ...
2
votes
1
answer
135
views
Golang solution to CTCI 1.2: Check whether two strings are permutations of each other
Just started learning Go recently. Did some questions from Cracking the Coding Interview book. Wrote the solutions in Go. Let me know what you think.
https://github.com/samjingwen/ctci
Below is ...
9
votes
6
answers
4k
views
Conway's Game of Life Object oriented implementation in Java
I have designed Conway's Game of Life in Java, the solution follows Object Oriented design and paradigm, please review and let me know the feedback
Class Cell
Cell ...
2
votes
1
answer
1k
views
Parse a log file into separate column files
This is a follow-up to https://stackoverflow.com/questions/71194832/converting-json-based-log-into-column-format-i-e-one-file-per-column .
My task is to optimize this code whose function is to convert ...
1
vote
1
answer
278
views
Another Vending Machine implementing State Pattern
I previously asked for a review for a Vending Machine implementing State Pattern in this linked post.
And received an answer from @radarbob. The code below is my revised attempt based on some of @...
5
votes
1
answer
479
views
Vending Machine implementing State Pattern
I was asked to implement a Vending Machine in a recent interview coding challenge. My attempt at a solution is based on the state pattern.
I would like to get some code reviews on this bearing in mind ...
2
votes
0
answers
58
views
Coding style of solution of the "Regular Expression Matching" problem on LeetCode
"Regular Expression Matching" is a hard problem on LeetCode (problem #10):
Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where:
...
4
votes
2
answers
824
views
Coding style and idiomaticity of solution to the Word Search II problem on LeetCode
"Word Search II" is a hard problem on LeetCode (problem #212):
Given an m x n board of characters and a list of strings words, return all words on the board.
Each word must be constructed ...
1
vote
1
answer
77
views
Reverse a sublist of a singly-linked master list in constant space and maximum of one pass (Java)
So I found this funky programming challenge somewhere on Quora. The idea is to take the head of a singly-linked list, and reverse a specific sublist. The requirements are:
runs in constant space,
...
3
votes
3
answers
413
views
Find smaller angle between minute and hour hands of clock
In this code the angle between the minute and hour hands of an analog clock are found and calculated and the smaller angle between them returned. This code works perfectly and I am getting back the ...
4
votes
1
answer
156
views
Return the biggest loss a client made from prices list
A hiring company gave me the following challenge:
We want a function which accepts a very large list of prices (pricesLst) and returns the largest possible loss a ...
3
votes
1
answer
74
views
Proper way of using redux and props
I made a weather app in react and redux for an interview. The response was that I didn't use redux properly, and that it has unnecessary props. I'm not sure what they meant.
The app is on github https:...
4
votes
4
answers
2k
views
Model animals using inheritance in Java, revised
Yesterday I posted my first solution to an interview problem here. I am now aware that I have many weak spots in Java and need to do extensive review before tackling any more interviews. Having said ...
1
vote
1
answer
374
views
Model animals using inheritance in Java
I was assigned the following problem:
You've gone back in time to 500BC Athens and Socrates wants you
to build him an app to help classify animals.
Build the classes ...
1
vote
1
answer
730
views
Printing odd and even numbers in separate threads C++
I recently saw a youtube video on printing even and odd numbers from 0 to 100 in Java. https://www.youtube.com/watch?v=eRNTx8k5cmA
Thread 1 prints even numbers and thread 2 prints odd numbers. Both ...
3
votes
2
answers
181
views
Check for max value in stack
Got this problem in a coding interview -
Get the max value of a stack in O(1).
The stack contains numbers only.
Please review my solution.
...
2
votes
3
answers
957
views
Find the 'n' most frequent words in a text, aka word frequency
I'm doing freeCodeCamp's Coding Interview Prep to improve my JavaScript skills. This challenge is called "Word Frequency", and is based on the Rosetta Code's entry of the same name.
The ...
2
votes
2
answers
372
views
Fake Interview Scenario: Hangman
For a fake interview I decided to write Hangman. The first question I have is when reviewing someone's code for a job interview is it more important to write something short and sweet that gets the ...
-1
votes
1
answer
312
views
Hackerrank Gridland Metro - using Interval Cover Solution [closed]
Hi there I was hoping to get a better grasp of greddy algorithms while trying to solve this problem: Hackerrank: Gridland Metro and I was trying to apply an algorithm where each grid could be ...
4
votes
3
answers
615
views
Compute shortest path in undirected graph
In a recent coding interview I was asked to write a program which takes as input two text lines:
The first one represents a graph, formatted as a sequence of undirected edges like ...
0
votes
2
answers
1k
views
Interview: Drug Analyzer class
the introduction is this:
You are a member of a biotechnology programming team that is responsible for creating a system for lab technicians, which will assist them with drug analysis.
Your goal is ...
5
votes
1
answer
694
views
Designing an URL Shortener
Recently I was assigned a URL shortener design problem while interviewing with a well known organization. Here is the exact problem statement:
Build a simple URL shortener service that will accept a ...
1
vote
1
answer
326
views
Square Spiral Matrix in Javascript
I've been grinding some Leetcode for an interview coming up and just completed Square Spiral in Javascript.
Looking for feedback on performance. This ranked faster than 58% of submissions, would there ...
1
vote
1
answer
118
views
Is My Controller too Coupling?
To put it in context, I had the assignment to do for a job interview in Node.JS, which basically making CRUD with products (and it have certain conditions).
The assignment was well-understandable, and ...
6
votes
1
answer
1k
views
friend locator app
I was rejected after a tech screening for the following code.
I mainly struggled to make the code 'production ready'.
I was running out of time so I did not create a class for testing.
How could I ...
2
votes
2
answers
106
views
Print Binary coded decimal Numbering of a given input number
Example 1
input:3
output:0011
Example 2
input : 15
output: 1111
in the below example code 15 is input.
I have taken 8 4 2 1 as array for Binary coded decimal numbering
this code is working as ...
3
votes
3
answers
1k
views
Printing rotations of an array 7 times
Loop through a given array 7 times and print the following output:
int[] arr = { 9, 2, 7, 4, 6, 1, 3 };
...
0
votes
2
answers
104
views
React Native screen to add a city to a weather app using a REST API
In a recruitment process, the company gives me a project to do in react native. I finished all the tasks. But company gave me a feedback and said that your project was good, but you did not apply best ...