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

learn more… | top users | synonyms (1)

10
votes
6answers
463 views

Scoring a Scrabble Word

I was asked before an interview to create a console application that will work out the score of a word for the board game scrabble. It worked fine but the feedback I received said: "there were no ...
7
votes
3answers
212 views

Calculating the area of a circle

This is one of tasks, which I had to do for the recruitment process at some company. Unfortunately they didn't like it so I've decided to share it here for discussion. CircleArea.h ...
2
votes
1answer
42 views

Find pairs in an integer array whose sum == 10

I'm practicing for technical interviews and I'm looking for ways to improve my answers/code. Please point out the flaws you see and how I can make this better. Task: Find pairs in an integer array ...
-2
votes
2answers
60 views

Comparing 2 ints without using comparative operators

I was looking for questions that might be asked in a technical interview and I found this one: Write a function that determines if two integers are equal without using any comparative operators. ...
-2
votes
1answer
99 views

Find the GCD for given array of elements [closed]

I had faced a interview question to find the gdc(greatest common divisor) for an integer array of element in optimised way : ...
5
votes
2answers
64 views

Return a rank for string of letters based on alphabetical permutations

So, first off, a little bit of unrelated information: I am preparing for a technical interview. I was reading this article, How to Prepare for (and Ace) the Technical Interview, by Rich Hein and I ...
10
votes
1answer
78 views

Top wiki pages as an app

I recently did an interview task. I was rejected because of bad code quality. There was two tasks. Here I will present the first, second will be posted in time. This project is avalible on GitHub ...
4
votes
4answers
121 views

Find Kth largest element in an array

I am preparing for interviews where my code would be judged based on optimizations, OOP concepts, code readability as well as my knowledge of JAVA and design patterns. What comments will you give in ...
3
votes
3answers
132 views

Reversing strings using recursion

I'm trying to solve exercises where I am required to use recursion. I wrote this: ...
3
votes
1answer
175 views

Find the kth largest element of an array

Find the kth largest element in an array of integers. You may assume that 1 <= k <=size(array) Any comments? Is there a more efficient solution? ...
3
votes
3answers
89 views

Number of right cyclic shifts to give the biggest number

I am preparing to coding interview and I met this task today: You are given 30-bit unsigned integer N. A right cyclic shift of N by K bits is the result of performing a right cyclic shift of N by one ...
3
votes
3answers
155 views

Letter combinations of phone dial pad number

In preparation for interviews, I have written a solution to this question: Given a sequence of numbers (34128) and an input map such as a dial pad on a phone (2->[a,b,c], 3->[d,e,f], ...
17
votes
6answers
2k views

Sales Tax Problem, rejected for not being up to their standards

I applied for a Junior .NET Developer Position recently, and I was asked to solve a problem (Sales Tax Program) and I was rejected for some reason. The question goes like this: Basic sales tax is ...
11
votes
2answers
134 views

Did not pass the interview about an RPN Calculator

I recently received a simple interview assignment as to implement an RPN calculator in Ruby. The program takes user input and quits when the user presses 'q'. I did it in under 30 minutes and was ...
34
votes
3answers
3k views

Sorting millions of integers

Last Friday I was hit with a sorting interview question that I never really had to deal with. Develop a your own sorting algorithm. It cannot use any other Classes for help. It needs ...
4
votes
2answers
341 views

Merging sorted arrays

I'd like to know if it's ok to write like this or there is a better, prettier way to do this. The merging itself is ok. I'm more interested in dealing with the situation when one of the arrays is ...
5
votes
1answer
102 views

Given a binary tree, compute the min depth of a leaf node

Here is the source of the question. They don't require a tree to be a BST, but my tree is. The algorithm would be the same for a simple binary tree. And there are two implementations: A recursive ...
6
votes
3answers
176 views

Finding clusters in a matrix

I got asked at an interview to write a program that, given a NxM matrix with zeros and ones, prints out the list of clusters of 1s. The clusters are defined as patches of 1s connected horizontally, ...
42
votes
10answers
4k views

Sales tax calculator, rejected for being not OOP

I applied for an Application Developer position. They require all their applicants to complete 1 of 3 programming assignments. I picked one for sales tax calculation. It was quite simple. ...
2
votes
2answers
203 views

Survivor programming challenge

I am working on a survivor problem: Complete Question Text: Take a second to imagine that you are in a room with 100 chairs arranged in a circle. These chairs are numbered sequentially from ...
15
votes
3answers
2k views

Finding anagrams - Empires strike back

Recently as part of a job interview I was given the following coding task: Attached is a gzipped text file of about 100,000 English words. Write a Python, C or C++ program that finds all the ...
4
votes
7answers
163 views

Printing a multiplication table

I was recently given a coding test by an employer. After the test, this was the employer's response: "I’d say that a lot of his solutions were pretty inefficient and took a very ‘brute force’ ...
14
votes
5answers
560 views

Given a sequence of positive integers A and an integer T, return true if a continuous sequence of A sums up to exactly T

Here is the source of the question, and my solution is below. Did I determine the worst case correctly? If you find any input where it doesn't work, please let me know. ...
2
votes
1answer
77 views

Highest pit - only climbing through the pit once

For a problem description, see other question. Imagine I would write this code at an interview. What would you say? Time complexity: \$O(n)\$ Space complexity: \$O(n)\$ Auxiliary space complexity: ...
2
votes
1answer
387 views

Find the max. difference between two array elements a[j] and a[i] such that j > i

The source of the problem is here. Given an array of integer elements, return the maximum difference of any pair of numbers such that the larger number of the pair occurs at a higher index ...
3
votes
0answers
49 views

Evaluating an expression with integers, +, and *, as well as -, / - revision 2 [duplicate]

The question came from this web site, and the first round of code review is here. The calculator which only supports the signs + and ...
5
votes
2answers
277 views

Android App Interview (Minesweeper game)

I recently did an Android Minesweeper app for a pre-interview coding challenge before I could talk to any engineer and was rejected. This feedback was given but I'm not sure on some of it. ☺︎ Game ...
4
votes
2answers
306 views

Evaluating an expression with integers, +, and *, as well as -, /

There is a job interview question, and the source of the question is here. The solution is pretty simple. We just need to split the input string by + and then by *. Then we compute products in a ...
5
votes
3answers
141 views

Summing the first 1 to n powers of 2

At a JavaScript test for a job, I was asked the question below. I refuse to believe there isn't a better way to accomplish the same result, but I couldn't find any. If some JavaScript geek would take ...
3
votes
2answers
115 views

Simple Factorial Interview Task

I did this code for an interview. Can you tell me how it looks? I didn't get the job, so I'm wondering what I could do better in my code. ...
1
vote
2answers
68 views

Passing text through a network of transformation modules (task #4)

About a year ago, I was given a C++ assignment as a preliminary job-interview test. The assignment included 4 different tasks, from which I had to choose one. I actually chose and completed 3 out of ...
1
vote
1answer
57 views

Beat count-to-time converter (task #2)

About a year ago, I was given a C++ assignment as a preliminary job-interview test. The assignment included 4 different tasks, from which I had to choose one. I actually chose and completed 3 out of ...
2
votes
1answer
52 views

Rhythm notation converter (task #1)

About a year ago, I was given a C++ assignment as a preliminary job-interview test. The assignment included 4 different tasks, from which I had to choose one. I actually chose and completed 3 out of ...
0
votes
1answer
70 views

Displaying information served on the client

I recently did a coding problem for an interview that unfortunately led me to not getting the position. So I figured I'd get the code reviewed by other professionals because after asking about the ...
17
votes
2answers
730 views

Designing another Coffee Machine Application

After reading Designing a coffee machine yesterday, I decided I could also give the same problem a try. I have used the following problem statement (copied from the given question): Design a ...
27
votes
5answers
4k views

Designing a coffee machine

I was recently rejected from what looked like a really promising string of interviews. I did very well in a questionnaire style review, and then they handed me this assignment (more or less): ...
3
votes
1answer
49 views

Acquiring indices for anagrams of an input string

I am working on an interview question from Amazon Software: Design an algorithm to take a list of strings as well as a single input string, and return the indices of the list which are anagrams of ...
6
votes
2answers
235 views

Finding pairs of numbers within A that add up to N

I am working on an interview question from Amazon Software Interview: Given an integer N and an array of unsorted integers A find all pairs of numbers within A which add up to N I have a working ...
3
votes
1answer
88 views

Letter Combinations of a Phone Number

I was asked to code a solution in Python in 15 mins. Print all possible word combinations for a given phone number. Numbers 0 and 1 will not be part of the phone number, the numbers can be repeated, ...
4
votes
2answers
417 views

Non-recursive method for finding a ^ n

I am working on an interview question from Amazon Software. The particular question I am working on is "to write a program to find an." Here is my recursive solution to this problem (in Java): ...
3
votes
1answer
158 views

Find the smallest number of square numbers to create n

An interview question I got - Given int n, find the smallest number of square numbers that fit inside n. Example: ...
3
votes
2answers
134 views

Removing duplicates from an array

I recently wrote this JavaScript algorithm for removing duplicates from an array as part of a job interview process, but was turned down for the position after submitting the code. I didn't receive ...
3
votes
2answers
171 views

Immutable Queue in Java using an Immutable Stack

I am new to this Immutability concept and I have some coding experience in JAVA. Recently as a part of internship program, they gave me a 5-day task, which was to implement Immutable Queue. After some ...
3
votes
3answers
205 views

Determining if a pair exists in a large sorted array

I'm doing practice interview questions from here. Here is the one I am currently on - if you are given a very large sorted int array, then check of there exists a ...
1
vote
1answer
91 views

Count the accumulated rainfall in a 2D mountain range

Challenge: Count how much rain will be collected in the valleys between the peaks of a mountain range in a 2D world. The mountain range is defined by a single array of positive ...
2
votes
2answers
161 views

Counting a cycle

An interview question I got - Each element of an int array points to the another element, eventually creating a cycle. Starting at ...
8
votes
3answers
211 views

Computing the relative magnitude of the values in one double array to another

An interview question I received: You are given two unsorted lists of positive doubles x contains the results from experiment 1 ...
34
votes
12answers
4k views

Efficiently squaring each element in a sorted array, keeping it sorted

The other day I was asked the following question during an interview: Given a sorted array, how would you square each element of this array, while keeping it sorted? I froze up and wrote a ...
5
votes
2answers
363 views

Find if a word with wildcard exists in dictionary [closed]

This is a question from a phone interview I had. The question was in 2 parts: a. find("cat") -> T/F suggest a data structure to find is if a word exists in a large dictionary, how will one node ...
3
votes
2answers
666 views

Elevator program code challenge

I recently applied for a job where the company gave me the following prompt for a code challenge. They have since told me "yeah, no thanks" but provided me with no feedback about why they came to that ...