Questions tagged [interview-questions]

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

Filter by
Sorted by
Tagged with
2
votes
2answers
133 views

Ruby implementation for Hacker Rank connected cells in a grid

https://www.hackerrank.com/challenges/connected-cell-in-a-grid/problem problem statement: Consider a matrix where each cell contains either a 1 or a 0. Any cell containing a 1 is called a ...
1
vote
1answer
1k views

Print odd and even numbers using two threads in Java

I was asked below question in an interview where I need to print out even and odd numbers using two threads so I came up with below code one without synchronization and other with synchronization. <...
6
votes
4answers
100 views

LeetCode ZigZag helper function code

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) ...
6
votes
5answers
4k views

Simple online auction system in Java

I recently applied for a Java developer position and I was asked to completed a coding task. After review of the coding task, the company said they do not want to take me forward to interview. They ...
3
votes
1answer
64 views

Find minimal number of days to meet all your friends

I was asked this in an interview yesterday: You get an array of segments (segment contains 2 numbers, representing days count (say in a month, but could be in a year, etc.): start, end). You need to ...
13
votes
3answers
11k views

Get all combinations of selecting k elements from an n-sized array

Was asked this today in an interview. Didn't see it before, and spent quite a lot of time getting it to work (tricky with all the recursion). The goal was to find all possible combinations of ...
13
votes
1answer
970 views

Interview coding challenge for iOS Part 2 - the application in Objective-C and Swift

I recently interviewed with a company that needed a C/C++ programmer to work on the iOS side of the products. The job description indicated they needed someone with 4 years of Objective-C and iOS ...
3
votes
1answer
29 views

T-SQL Query remove duplicates except for original row from the table

Question: There is an Exam_Merge table into which to import records from a similarly structured table in another database. In this case, the Exam_Merge table contains the values of the primary key ID ...
2
votes
1answer
44 views

System Dependency Manager - Ruby

I recently got a prompt when looking for a job. To spare any details, the company decided not to get back to me, so because I did not get a code-review/feedback from them, I was wondering if someone ...
2
votes
5answers
801 views

Award Budget Cuts implementation in Java

PRAMP Award Budget Cuts The awards committee of your alma mater (i.e. your college/university) asked for your assistance with a budget allocation problem they’re facing. Originally, the committee ...
2
votes
1answer
448 views

Time schedule intersection

I had a job interview one of the questions was the following Given an api - you submit a name of a person and it gives back a sorted list of all the free time slots this person has. the list might be ...
8
votes
2answers
89 views

Function invocation every second time

Recently I got test task at the project, it is fairly simple: ...
8
votes
1answer
5k views

Highest pit - only climbing through the pit once

Problem description: A non-empty zero-indexed array A consisting of N integers is given. A pit in this array is any triplet of integers (P, Q, R) such that: 0 ≤ P < Q < R < N; ...
5
votes
4answers
370 views

Maximum character insertion

I would like to know any suggestions about to improve my code and/or get a better approach for this problem solution and your rating of my approach to the problem.(besides removing the ...
1
vote
1answer
75 views

T-SQL query Choose name of clients, concluded more than one loan agreement in 2010

QUESTION: Choose the name of clients, concluded more than one loan agreement in 2010, as the numbers and dates of issue of these contracts. Sort by name of the client and date of issue of the loan. ...
3
votes
2answers
227 views

Calculate the largest palindromic number from the product of two 6-digit numbers (100000 to 999999)

Are there any efficient ways to solve this problem, for example using bitwise operator? ...
3
votes
1answer
99 views

Jumping on the clouds

I have started the Hackerrank interview preparation kit. The first problem I have solved with Swift is as follows: Emma is playing a new mobile game that starts with consecutively numbered clouds. ...
7
votes
5answers
190 views

String combinations of 0 and 1

I was asked this question in an interview: Given a string s consisting of 0, 1 and ...
7
votes
6answers
1k views

Find max number you can create from an array of numbers

Was asked this in an interview yesterday: You are given an array of numbers (not digits, but numbers: e.g. 9, 23, 184, 102, etc.) - you need to construct the largest number from it. For example: you ...
3
votes
1answer
82 views

Find the largest product of an array

This task is taken from www.interviewbit.com Given an array of integers, return the highest product possible by multiplying 3 numbers from the array Input: ...
5
votes
1answer
13k views

Count duplicates in a JavaScript array

This is actually a hackerrank interview question I have already solved but I need guidance on how to optimize it for the Time Space Given an array of integers, your task is to count the number of ...
0
votes
2answers
63 views

Count Substrings for a binary string

Problem is taken from leet code. Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings ...
3
votes
3answers
243 views

Frequency analysis based anagram checker

I uploaded code solutions for some problems of the book Cracking the Coding Interview, 6th Edition to GitHub, I would like to know your rating and potential improvement of the code I wrote. Here is ...
7
votes
2answers
3k views

Searching in a sorted 2D matrix

If I was at an interview, and wrote this code, what would you think? Please be brutal. Time it took to wrote it: 13 minutes Problem: Write an efficient algorithm that searches for a value in an m ...
2
votes
3answers
132 views

The last standing gunman in a circle

I don't know why in most of the interviews, interviewers are asking this question commonly. The question is: There are n number of persons standing in a circle. ...
6
votes
2answers
98 views

Find matching dictionary words given a Scrabble tray

This is a question I was asked in an interview, below is a cleaned-up copy of the answer I gave. Apparently this answer was not satisfactory. How can it be improved? Question: Given a dictionary of ...
1
vote
1answer
69 views

Rotate matrix clockWise and counter clockWise

This code is a mix of the same question one time rotating to the right and one time to the left. I tried to simplify the code since I'm struggling with all of the indexing here. https://leetcode.com/...
3
votes
1answer
52 views

CareerCup (Bloomberg): Check if string is valid based on brackets

The goal of this problem is to determine if a string with brackets is valid. Below is a summary of the question from careercup. Check if string s is valid based on brackets ...
7
votes
1answer
141 views

Build a set of REST interfaces using Symfony framework

I have got a technical challenge from a company but they reject my code and I'm not sure how to do this challenge in a more efficient way so I'm here to get some guidance. The Technical challenge was:...
4
votes
2answers
91 views

Find the in-order successor of a given node in a binary search tree

I have an implementation of an algorithm to return the in-order successor of a given node in a binary search tree. We are allowed to assume that each node in the BST has a reference to its parent node....
2
votes
2answers
62 views

Validating that a Java program has two equal-length arguments

I'm writing a small almost one method Java class for a job application and the advice given was to write it as though it was a piece of commercial software. The ...
2
votes
0answers
124 views

Event management system in C++

I have this question asked as home assignment for an interview. I submitted my solution and did not get selected. Wanted to know your feedback for the solution. Question: Write a very simple ...
7
votes
1answer
145 views

Drone Delivery Scheduling Service

I recently did a interview with WalmartLabs. I was tasked with a take home assignment. I didn't sign a NDA and a team at WalmartLabs said I could post the code on GitHub. I was tasked with developing ...
5
votes
1answer
126 views

In-Memory database supporting transactions

I referred to the post here but it does not address the question that I have with regards to my implementation. I have a C# implementation of an in-memory database that I came up with during a recent ...
4
votes
1answer
178 views

SQL query to count loans issued during each week

Calculate the number of loans issued by the Regional offices for each business week in the period from 38 to 40 business week of 2011 inclusive. Sort by name of the regional unit, business week. ...
5
votes
1answer
74 views

PHP program to validate phone numbers from a file

As part of job interview, I was asked to write a cli script that takes a list of phone numbers to validate from a file and as an option in the command line. It will then produce a CSV file with three ...
5
votes
1answer
921 views

LRU Cache Implementation with HashTable and LinkedList

Problem Statement: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the value (will always be ...
54
votes
11answers
12k 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. Write ...
3
votes
1answer
591 views

“Can a list of meetings all be scheduled in a conference room?”

I was given this question at an interview for a position I just got rejected by, so looking to improve and see what better answers there are! ...
4
votes
1answer
863 views

A tax calculator application to calculate tax and print final receipt

Although this question has been asked a lot of times, I was hoping for a feedback on my approach. Tax Calculator Basic sales tax is applicable at a rate of 10% on all goods, except books, food, ...
2
votes
0answers
74 views

Longest Palindrome Substring: Where is the dynamic programming? [closed]

In this LeetCode problem, Longest Palindromic Substring, it is listed under Dynamic Programming for Google interview preparation. My understanding of dynamic programming is roughly "recursion + ...
3
votes
3answers
253 views

Intersection of the interval set

Recently I had an interview where it was asked: Given a list of people with their birth and end years find the year with the most number of people alive. I implemented in Java and was trying to find ...
7
votes
4answers
496 views

Calculating linux based octal file permission

I'm applying for a mid level devloper position. In order to progress to 2nd interview, you need to pass a technical test. One of the questions was to write a function to work out linux based octal ...
3
votes
1answer
58 views

Adding two numbers represented as linked lists

I have some imminent interviews and want to sharpen my game before going into them. I'm running through some practice problems. This LeetCode challenge is to add two numbers represented as linked ...
1
vote
2answers
130 views

Leetcode - find if BST is valid or not

Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node'...
4
votes
2answers
361 views

How to set an interval to std::map [closed]

This code belongs to a contest. I tried to apply the range of data to a std::map. The contest system however warns me that the implementation of the assign function ...
1
vote
1answer
52 views

Find the combination of matches which are closest to each other

Problem - Given three sorted arrays find combinations which are closest to each other. example - ...
1
vote
1answer
32 views

Leetcode - product of array except self

Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Example: ...
1
vote
1answer
143 views

Longest Substring Without Repeating Characters in Scala

Question is taken from Leetcode and solution works for their test cases. I do see a scope of improvement and make it more functional (getting rid of vars and mutables data structures). Please suggest ...
3
votes
2answers
76 views

Leetcode - First Unique Character in a String

Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: ...