This tag is for questions that came up in an interview.
6
votes
1answer
142 views
Finding anagrams
I recently had a potential employer send me a programming test to read through a file and write to another file all the words that were anagrams (two or more words containing the same letter). The ...
4
votes
2answers
65 views
Reverse all the words in a given string
I have read this and I want to know how the solution that I came up with in my interview compares with the top solution.
...
-3
votes
0answers
14 views
binary search tree in java [on hold]
I am trying to write a java code for binary search tree.The program includes insert,delete,check empty and print features for tree.But I am not able to insert nor delete any node in the tree.please ...
7
votes
4answers
205 views
Add one to a very large integer
I was asked to implement this in an interview a while back. I didn't pass the interview, mostly likely because it took me far too long to do. However, I'm interested to know how well implemented the ...
4
votes
2answers
66 views
App to list books from JSON data
I recently submitted the code for this for an 2 hour interview but I was rejected.
The app shows book information with a image, title, and author. Each entry has a title but some entries have no ...
5
votes
2answers
99 views
Project Euler problem 79: deducing a passcode
For one place that I interviewed at (for a Python developer position) I worked with one of the devs on two Project Euler problems, one being problem 79. We talked through different approaches and came ...
2
votes
0answers
35 views
Are AVL trees equal? - revision 3
The original question
Given two binary trees, return true if they are structurally
identical, and false otherwise.
Are AVL trees equal?
Are AVL trees equal? - revision 2
This revision on ...
0
votes
1answer
32 views
Taking a node in rootA and finding a clone node in other tree
I was asked this as an interview question. I was also asked to assume that there is a function which can compare and say two nodes are identical. I would like to implement that function as well. I'm ...
2
votes
3answers
73 views
Reverse part of a linked list
I'm learning data structures. I'm working on linked lists at the moment, and I'd like to have a strong grasp on them. Below is the last problem I solved. I'd like to know what you think of the ...
2
votes
0answers
42 views
Bank account data structure
I need to model simple account data structure. The user should be able:
to add a transaction
get information about transaction
take all transaction of some type
sum a transaction and all its ...
6
votes
3answers
377 views
Checking balanced parenthesis string
I recently wrote a code in online recruitment test. It was very good.
With each question, there were associated space and time limits check. If our code executed correctly within both limits, only ...
1
vote
1answer
47 views
Are AVL trees equal? - revision 2
Revision 1.
This revision on GitHub
In addition to the solution itself, I wrote tests for all the possible
cases.
It seems you have verified all execution paths are covered.
You are ...
21
votes
3answers
2k views
Java Inventory System
I'm often applying to jobs just to test out my skills. I have recently applied to one, had to submit a Java problem, but got rejected. Could someone please review my application briefly and tell me ...
4
votes
2answers
183 views
Maze solver for 2D matrix in Ruby
I got rejected for a junior Ruby job entry where I had to solve a 2D matrix as a maze with walls.
This is the main class:
solver.rb
...
4
votes
1answer
73 views
Water accumulated between towers
I came across this interview question to find water accumulated between towers:
You are given an input array whose each element represents the height of the tower. The width of every tower is 1. ...
6
votes
2answers
313 views
Implement Java hasNext() and next() in C++
Recently came upon this question asked in interview with major tech company.
Implement Java's next and hasNext function in your favorite
programming language.
Here is the solution I came up ...
6
votes
1answer
117 views
JavaScript program to count lines of Java code
I've implemented a small program in JavaScript to count the number of lines of a string of java source code.
This was done for one of the Code Kata exercise: ...
3
votes
4answers
92 views
Sending templatized e-mail to a million contacts
This code runs fine without a bug, I need to optimize this code for following interview requirement.
Lets say i need to send it to 1 million contacts and emailBody is ~100Kb.
What code optimization ...
2
votes
1answer
48 views
Get K most frequent tokens from a token stream
This is an interview problem:
Given a token stream, find the K most frequent tokens in real time (the order of these k tokens does not matter).
My approach:
Use a hash table (...
2
votes
1answer
96 views
Function to compare phone numbers
I got rejected in tech screen yesterday. I was asked to write a JavaScript function and send it over email. The question was(I have added the full question below). I have also added hiring manager's ...
6
votes
3answers
354 views
Finding the postion of a substring in a string
I am given two strings and return the position if in the larger string the smaller string is found. If not I am returning -1 for position. Any suggestions for improving my code.
...
7
votes
1answer
189 views
Are AVL trees equal?
I was inspired by this answer and decided to implement an AVL tree with the methods equals and hashCode as if I was asked to do ...
7
votes
1answer
83 views
Designing yet another coffee machine, Lombok style
After reading Designing a coffee machine, I decided to implement the same problem as an exercise to get to know Guava and Lombok.
I used the problem statement from the given question:
Design ...
-3
votes
1answer
91 views
Implemented Stack using array
I'm going to job interviews soon. How I can improve my coding style and write better code?
...
4
votes
1answer
71 views
Swap items of a linked list in pairs - revision 5
Here is the source of the question.
Given a singly linked list, swap the list items in pairs (reconnect
the pointers, not simply swap the values). For example:
Before: A->B->C->D
...
2
votes
2answers
74 views
Hike in recession by a company based on criteria
I was going through design questions frequently being discussed in interviews and have found a problem which states:
Consider a company which wants to process salary hikes of its
employees ...
5
votes
4answers
365 views
Find the common element in two int arrays
I am preparing for a interview for a junior level c# position. I take two arrays and find the common int between both of them. Let me know if you have any feedback.
...
4
votes
3answers
291 views
Most common occurrence of an int in an array
I am prepping for a junior level interview in C#. I am hoping I can get some feedback on how to improve my code to print the most common occurrence of an int in an ...
1
vote
1answer
63 views
Swap items of a linked list in pairs - revision 4
Here is the source of the question.
The solution on GitHub.
Revision 1.
Revision 2.
Revision 3.
@200_success' suggestions from revision 3:
The iterator's ...
2
votes
1answer
36 views
Swap items of a linked list in pairs - revision 3
Here is the source of the question.
Revision 1.
Revision 2.
When I started the second round of code review, I wanted to make sure that I had included all the possible input types. However, I ...
3
votes
1answer
70 views
Checking for uniqueness within a string
I saw this interview question in the book Cracking the Coding Interview:
Implement an algorithm to determine if a string has all unique characters
The authors solution uses bit-shifting for a ...
10
votes
4answers
868 views
Method to count all comments in single external C# file
I recently had an interview question:
Write a method that counts all comments in a single external file.
It was a timed question and I wanted to know if this is the best way to accomplish the ...
3
votes
1answer
75 views
Swap items of a linked list in pairs - revision 2
The first revision is available here and the code is available on GitHub. I modified the method reversePairs and added mSize to ...
11
votes
1answer
150 views
Concurrency interview
A little while back I had an interview where they posed a problem, in summary:
Watch a certain directory, and process incoming JSON files
These JSON files have various "Type" fields
Every second ...
10
votes
1answer
158 views
House-coloring optimization challenge
I have an interview coming up in the next few weeks, and I'm choosing to be interviewed in Python. I began programming in Python (it was about four years ago), so the syntax is natural to me, but I ...
2
votes
1answer
151 views
Swap items of a linked list in pairs
Here is the source of the question:
GitHub
Given a singly linked list, swap the list items in pairs (reconnect
the pointers, not simply swap the values). For example:
Before: A->B->C->D
...
7
votes
2answers
268 views
Determine if string has all unique characters
I'm working my way through the exercises of the book Cracking the Coding Interview. I'd like to review my solution for the question:
Implement an algorithm to determine of a string has all unique ...
10
votes
1answer
263 views
Robot toy simulator
I have already flunked the test with this code so don't feel bad for cheating any employer. I didn't get any feedback though just wondering what could have gone wrong.
You don't need to get into the ...
5
votes
2answers
177 views
C++ 2D shape intersections - template reduction
I've created a short piece of code to determine whether or not various 2D shapes (circles/lines/rectangles) intersect. It was a job interview question, but now it's just about self-improvement.
I'd ...
5
votes
4answers
297 views
Sufficient implementation of subset sum for 45 min interview
I am preparing for interviews, and have implemented a solution to this problem from Geeks for Geeks:
Given a set of non-negative integers, and a value sum, determine if there is a subset of the ...
2
votes
1answer
134 views
Interview adjacency list graph problems in C++: proper graph implementation
I know this type of question has been asked before. However, my reason for asking it is gaining insight into what is expected in a 45 min interview when asked to implement graph algorithms. I have ...
11
votes
7answers
1k 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
259 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
198 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
140 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
184 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
260 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 ...
11
votes
1answer
94 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
216 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
176 views
Reversing strings using recursion
I'm trying to solve exercises where I am required to use recursion. I wrote this:
...