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

learn more… | top users | synonyms (2)

1
vote
1answer
43 views

Non-persistent storage for key-value pairs

I got an interesting interview question related to JavaScript: In JAVASCRIPT please create a storing function called storingFn with the following characteristics:...
6
votes
2answers
128 views

Find K biggest numbers in the array

I was trying to implement method number 2, from this article. Method 2 (Use temporary array) K largest elements from arr[0..n-1] Store the first k elements in a temporary array temp[0..k-1]....
7
votes
1answer
99 views

Hackerrank - value of friendship (II)

Problem statement You're researching friendships between groups \$n\$ of new college students where each student is distinctly numbered from \$1\$ to \$n\$. At the beginning of the semester, no ...
2
votes
1answer
81 views

DFS algorithm + unit test

Please comment on my DFS implementation and test, I would like to get comments about algorithm correctness. Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data ...
3
votes
1answer
48 views

Find the biggest rectangle in a bar graph

Find the largest rectangle area on a bar graph. Example: if you had a graph of 1,4,5,3,3,5 the answer would be 15 (3x5) which is formed by the rectangle that is 3 high and spans from position 2 (1 ...
2
votes
1answer
126 views

Count the number of times a particular number appears in a sorted array of integers

I had an interview question awhile back that went more or less as follows: You have a sorted array of integers representing the ages of every person living on earth. There's a single entry in the ...
3
votes
0answers
50 views

Merge two sorted linked lists in C++

Should I be using std::move or copy when passing LNode in the LinkedList constructor instead ...
5
votes
0answers
37 views

CtCi 2.6: Implement a function to check if a linked list is a palindrome

I would appreciate feedback on the linked list implementation and usage below for question 2.6 from Cracking the coding interview book. ...
6
votes
1answer
1k views

What's wrong with this FizzBuzz?

The rules are unsurprisingly: Write a program that prints the numbers from 0 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For ...
1
vote
2answers
266 views

Hackerrank: Connected Cells in a Grid

Problem statement Consider a matrix with \$n\$ rows and \$m\$ columns, where each cell contains either a \$0\$ or a \$1\$ and any cell containing a is called a filled cell. Two cells are said to be ...
13
votes
6answers
1k views

Detect the missing number in a randomly-sorted array

I was reviewing for an interview and encountered the following question (and I'm paraphrasing): Suppose you're given a shuffled array of numbers containing all of the numbers between a min and a ...
12
votes
4answers
943 views

Leetcode 15. 3 Sum

Problem statement Given an array S of n integers, are there elements a, ...
5
votes
1answer
197 views

Check if a given integer is power of two

Given an integer, check if it's the power of two. ...
3
votes
2answers
115 views

Insert node in sorted doubly linked list

Description: Given a reference to the head of a doubly-linked list and an integer, create a new Node object having data value and insert it into a sorted linked list. Code: ...
1
vote
1answer
35 views

Floyd's cycle detection algorithm in linked list

I am doing interview studying and would like to have another look at my implementation of Floyd's cycle detection algorithm. I've implemented a simple linked list which can be fluently configured ...
5
votes
1answer
55 views

Stack class in Ruby to calculate maximum number, get the average, pop, push

Is the class optimized enough to accept 1 million items in the stack? ...
8
votes
1answer
97 views

Determine when a task will be completed

A friend of mine told me he had the following exercises at his interview : You need to determine when a task will be completed if you are given : A date when the task is started The ...
8
votes
6answers
162 views

Implement queue using two stacks

Although it's a well-known algorithm, I thought to implement it from the perspective of a coding interview. I want to know if I can improve my code somehow. So, given the time constraint, is this a ...
5
votes
6answers
923 views

Python code to check if an array has a sequence (1,3,4)

I recently applied for a job as a Python coder but was rejected. This was the problem: Write a python code to check if an array has a sequence (1,3,4) Assuming they were looking for expert Python ...
4
votes
4answers
168 views

Given N and M find all stepping numbers in range N to M

The stepping number: A number is called as a stepping number if the adjacent digits have a difference of 1. e.g 123 is stepping number, but 358 is not a stepping number. Example: N =...
2
votes
2answers
232 views

Multiply two numbers

I am trying to implement multiplication of two numbers without using the * operator, as a practice for programming interviews. I have written two functions. 1) ...
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
4answers
250 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
208 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
122 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 ...
1
vote
1answer
317 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
64 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
104 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
168 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
973 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
101 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
779 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
63 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
70 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
72 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
80 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
142 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
81 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
188 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
206 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
217 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: ...
3
votes
4answers
80 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 ...
22
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
115 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
127 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
220 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
112 views

A roman to integer converter

For an interview question I made a roman to integer converter: ...
11
votes
1answer
125 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 ...