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

learn more… | top users | synonyms (2)

8
votes
5answers
1k views

FizzBuzz Implementation in Java

Fairly new to learning interview questions and I saw this one and gave it a shot. I would very much appreciate some constructive criticism of how I went about it and what you would tell me if you were ...
3
votes
3answers
157 views

Validate that brackets are balanced

I've done a test for a job (which I failed) and I'd like to know in which ways my code could've been better. Here are the questions and my answers, it's not very long. 1) Make a program that ...
3
votes
1answer
116 views

Read and write in C# buffer in parallel

I have a buffer - int array with defined length. I want to read and write values into this array in parallel. For instance, 5 readers and 3 writers with different ...
2
votes
3answers
102 views

Hackerrank Insertion Sort Algorithm 1 (creating duplicates to show shifting)

During an interview, I was given this Hackerrank question to solve within 15 minutes but at that time I was interested in solving this without performance in my mind. I know a similar question has ...
0
votes
1answer
115 views

Google FooBar Level 3 - Shortest path to 1

I recently found the Google Foobar challenges and am having a problem with level 3. The goal of the task is the find the minimum number of operations needed to transform a group of pellets down into 1,...
4
votes
1answer
51 views

Marketplace checkout system

I was given the following code challenge as part of an interview process, unfortunately I did not get through to the next stage. Any advice on how I could improve would be very much appreciated. Here ...
3
votes
1answer
101 views

Maximum product of 3 integers in an int array using Python - follow up

This is a follow up to Maximum product of 3 integers in an int array using Python Changes to the code include renamed variables for improved readability and I added more test cases. ...
3
votes
5answers
157 views

Maximum product of 3 integers in an int array using Python

This is an interview question from Interview Cake: Given a list_of_ints, find the highest_product you can get from three of the integers. The input list_of_ints will always have at least three ...
9
votes
5answers
960 views

Find first non-repetitive char in a string

I just had an interview for the C#.NET developer position and I was asked to find the first non repetitive char in a given string without using any library functions but just the basic constructs of ...
1
vote
3answers
91 views

Algorithm that receives a dictionary, converts it to a GET string, and is optimized for big data

I found this question online as an example from a technical interview and it seems to be a flawed question in many ways. It made me curious how I would answer it. So, If you were on a technical ...
4
votes
2answers
760 views

Checking the balanced parenthesis as asked in interview

Input: Input contains one string S which consists of big and small latin letters, digits, punctuation marks and brackets from the set []{}(). Constraint: Constraints. The length of S ...
4
votes
1answer
60 views

Based on a file containing people's names, output some statistics and generate some modified names

Noobie here. I applied for a job as a Jr. engineer and they gave me this task. After they read through my solution they rejected my application because the code was hard to follow. I'd like to get an ...
2
votes
0answers
63 views

JavaScript Node/React web developer interview code part 2 RESTful API

I recently applied for a job as a Node/React developer. I'm attempting to cross over from a research position to web development. I didn't get the job but all the feedback I got was that my code was ...
2
votes
0answers
67 views

Javascript node/react web developer interview code

I recently applied for a job as a node/react developer. I'm attempting to cross over from a research position to web development. I didn't get the job but all the feedback I got was that my code was ...
2
votes
2answers
71 views

Inverting a Scrabble letter score map

Question: The old system stored a list of letters per score: 1 point: "A", "E", "I", "O", "U", "L", "N", "R", "S", "T", 2 points: "D", "G", 3 points: "B", "C", "M", "P", 4 ...
2
votes
2answers
135 views

Class name search algorithm

Here is a test task from a company, where I'd like to work eventually. I solved all they wanted to me to do, however failed to get an interview. I do not know what is wrong with my solution, because ...
4
votes
2answers
75 views

Find max element in increasing-decreasing array

Question: Find the largest in a list that list is stored as two sections, one in ascending order and the other in descending order. Elements are distinct. E.g: Input ...
0
votes
1answer
106 views

Left rotation arrays algorithm

This is my solution to the common 'Array Rotation' algorithm. As I am currently practicing for coding interviews, I want to make sure that my code in fact valid for coding interview scenarios. Would I ...
7
votes
2answers
173 views

OOP Blackjack in Python

I worked on this for a software engineer interview as the take home challenge. The company came back with this constructive feedback: You made a slight mistake in ace handling that led to the ...
5
votes
3answers
1k views

Give me some change as asked in interview

Description: The goal in this problem is to find the minimum number of coins needed to change the input value (an integer) into coins with denominations 1, 5, and 10 The input consists of ...
3
votes
3answers
216 views

Fractional Knapack as asked in an interview

Description: Given the Knapsack capacity and the weight and value of some items, find a way to maximize the value in the given Knapsack. Code: ...
2
votes
4answers
74 views

Delete all elements from list whose sum with preceding element equals target value

Let me start off by saying that the question specifically implies using std::list<int> and not anything else AND you are allowed to iterate over the list only ...
21
votes
3answers
3k views

Keeping track of the tennis score

I'm trying to get hired by some company and they gave me a simple remote test to take at home so they can judge my coding skills. It's a really simple problem based on the website HackerRank. It's a ...
5
votes
2answers
109 views

Calculating cooccurrence probabilities for pairs of words in a document

It is a 1.5 hour coding test, started the moment when the question was sent by email. My solution was done under the strict condition. I was not told anything before the test. The question is about ...
3
votes
3answers
124 views

Template class to demonstrate array manipulation

Today I didn't pass the test task for the position C++ junior/middle developer. What i did wrong? Please help improve myself. Task: Description. Write a template class - an array of any type ...
12
votes
3answers
1k views

Building car factory with custom features per car

I was once asked in an interview to build a factory that makes cars. All cars has common features like price, rating and color and they have some features like fuel injection which can on specific car ...
2
votes
1answer
142 views

Pattern searching in 2d grid

This is an interview question which i am trying to solve. You are given a 2D array of characters and a character pattern. WAP to find if pattern is present in 2D array. Pattern can be in any way (all ...
5
votes
1answer
101 views

A roman to integer converter

For an interview question I made a roman to integer converter: ...
11
votes
1answer
124 views

Wandering water ways

An entry for the August 2016 Community Challenge I slightly modified the input and output to suit the snippet tool, and also because I really like the mapped output with the basins. I have been ...
6
votes
1answer
141 views

Implement 3 stacks using a single array in C++

One of the questions that is presented in Chapter 3 for Cracking the Coding Interview is this: Describe how you could use a single array to implement 3 stacks I'...
2
votes
1answer
149 views

Total number of stops for an elevator to serve certain people

I have seen this question asked around a bit, such as this Code Review question in Java: Write an optimal program that would determine the total number of stops a elevator has taken to serve X ...
0
votes
2answers
191 views

Google Foobar Challenge: Spy Snippets in Python [closed]

I am getting all the answers correct. But still the solution is not accepted as only 4/5 tests cases are passed. I have not posted the whole problem statement but the problem is similar to this. I ...
10
votes
1answer
206 views

Implementing a string class in C++

I recently attended an interview for a C++ position in a very reputed bank. The interviewer started off by asking me to implement a string class but was only interested in constructor, copy-...
7
votes
5answers
1k views

Interview solutions to reverse a string and reverse a sentence

Recently in an interview I was asked to Write a method to reverse a string. I used StringBuilder but was asked not to use reverse method of builder but iterate ...
0
votes
0answers
83 views

Find the kth largest element in an array

Is this idomatic scala code? ...
5
votes
2answers
77 views

Parsing shorts from binary file and finding the closest and furthest points

A few months ago I got rejected at the technical interview for a position. The problem that they gave me is the following: From a binary file, parse two shorts, x and y and build a Point object with ...
7
votes
1answer
147 views

Make Simultaneous HTTP Requests That Resolve Into a Single Return

This week, in an ongoing job search, I was tasked with the following pre-screening question: Make two simultaneous http requests. Use the language and library of your choice. Make sure the results ...
0
votes
2answers
63 views

Convert NSInteger into NSString

This is my sample code to convert a integer into string. Is it very costly to do the multiple loops of [NSMutableString stringWithFormat:..]? I.e should I just use appendString and get the NSString ...
7
votes
2answers
152 views

Load and analyze a list of people from a file

I recently completed a programming task in Java for a job that was javascript heavy but the hiring company wanted some Java knowledge. I've been using Java since the turn of the year. Other than ...
4
votes
3answers
189 views

Reversing a linked list (Java)

Triggered by an interview question (I didn't answer during the interview) I wrote a Java program to reverse a linked list. I went with a loop-based approach instead of recursion. I would like to know ...
3
votes
2answers
99 views

'Broken Record' Coding Challenge

I was asked to complete a coding challenge for an interview. The challenge being to write a test function to check whether or not a string was a broken record. A <...
7
votes
4answers
1k views

Implement an algorithm to determine if a string has all unique characters

I'm working through Cracking the Coding Interview. The first challenge is to implement an algorithm to determine if a string has all unique characters. I've gone through several iterations, but here'...
1
vote
2answers
64 views

Pseudo Promise.all() polyfill

A few years back I interviewed with a company for a Javascript position. After a couple of warm-up challenges I was presented with this: Please write a function that calls back with ...
5
votes
2answers
73 views

Java controller to farm out concurrent tasks

I've recently given a coding interview on a Java concurrency task and unfortunately didn't get the job. The worst part is I've given my best but now I'm not even sure where went wrong. Can anyone ...
4
votes
1answer
367 views

SVG photo mosaic creator

I got this as part of some interview assignment. After some head scratching I think I have done quite well as the result can be seen here: After transformation(10x10 tile): More crisp picture with ...
6
votes
3answers
321 views

Finding the duplicate with an array with 1,000,000 integers between 1 and 1,000,000

I recently had an interview and got to phase 2 which is a coding assessment. One of the questions was: Given an array with 1,000,000 integers between 1 and 1,000,000, one integer is in the array ...
12
votes
6answers
2k views

Find the first non-repeating character in a string: (“DEFD” → E)

I recently had an interview and got to phase 2 which is a coding assessment. One of the questions was: Find the first non-repeating character in a string: ("DEFD" --> E) I didn't pass the coding ...
1
vote
4answers
150 views

Program to display array elements in the ascending order of number of factors each element has

Input: 1000 23 100 26 32 Output: 23 26 32 100 1000 Since 23 has '2' factors and 26 has '4' factors and 32 has '6' ...
6
votes
3answers
253 views

Flatten an array

I have got this interview question which has asked me to write a production level code which flattens the arbitrary nested array of arrays. Code ...
6
votes
5answers
324 views

A custom String Builder implementation

Two code files below : the actual logic & the test logic. Core Logic ...