Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [interview-questions]

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

3
votes
2answers
29 views

Simple person manager console-app

The code below is for a coding challenge for a job. I have everything working as they requested, I've reviewed it myself and believe everything is good. I'm just looking to see if anyone see's ...
3
votes
1answer
34 views

A simplified Tetris solver

As part of an job interview process, I was tasked to write a solver for a simplified Tetris game using JavaScript. The game board size is 4x4 and there are 4 different pieces given in a .txt file. It ...
1
vote
0answers
45 views
+50

Automating A Workflow Using Selenium - Best Way To Fetch Elements & Make Code More Generic

I'm a newbie to Selenium and I'm trying to get better at it by taking up interview assignments. This YouTube link describes the workflow that needs to be automated. The following points are worth ...
2
votes
2answers
65 views

Return array with products of old array except i

Coding problem: Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i. My ...
2
votes
2answers
69 views

Is the sum of 2 numbers in list k

I got a coding problem to solve and was wondering if I got a commonly acceptable and efficient/clean solution. If there is a better way I'd gladly hear it. given a list with numbers return if the ...
0
votes
1answer
43 views

Find array index with element equality in Python

I was given this question during an interview. It is similar to binary search and I would like to ask for feedback for my solution. Array Index & Element Equality Given a sorted array arr ...
-1
votes
2answers
54 views

Two-sum solution in JavaScript [closed]

I was given this question during an interview. It is similar to two sum problems and I would like to ask for feedback for my solution. Merging 2 Packages Given a package with a weight limit ...
1
vote
2answers
69 views

Bracket matcher in Python

I would like to receive feedback on my coding interview for the following problem: Bracket Match A string of brackets is considered correctly matched if every opening bracket in the string ...
2
votes
2answers
44 views

Given entrance and exit logs, find the population maximum

I was given this problem during an interview. And I solved it using Python. Would like to get feedback to see how I can improve my interview response. Busiest Time in The Mall The Westfield ...
0
votes
2answers
74 views

Leetcode: Merging 2 sorted lists

https://leetcode.com/problems/merge-two-sorted-lists/ Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. ...
21
votes
3answers
4k views

Leetcode: Valid parentheses

https://leetcode.com/problems/valid-parentheses/ Given a string containing just the characters (, ), ...
9
votes
7answers
1k views

Versatile string validation

I passed a technical test the other day, one part included a cheap string validation and I am wondering this can be further improved to be more versatile to requirement changes. The requirements were ...
0
votes
2answers
35 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 ...
4
votes
1answer
145 views

Dijkstra algorithm implementation in Swift

I've implemented Dijkstra's algorithm to find the minimum path between two nodes. ...
1
vote
0answers
22 views

KMP algorithm in scala

I implemented KMP pattern matching algorithm in Scala. My code works but it looks more imperative and a scala translation of C/C++ implementation. I am not able to figure out how to manage multiple ...
2
votes
1answer
98 views

Family Relationship Tree

Developer Assignment - Family And Relations Going through the old stuff in his attic, Indiana comes across a chart which looks like a family tree of multiple generations which shows his ...
1
vote
1answer
99 views

Solving a multi variable polynomial

For this equation, I need to count possible solutions: $$ a + b^2 + c^3 + d^4 \le S $$ $$0\le a,b,c,d \le S$$ I tried the following approach: ...
2
votes
1answer
70 views

Rotate matrix 90 degrees

I recently did problem 1.7 Rotate Matrix in Cracking the Coding Interview. I realized my code is very different than what is in the book and what I am also fining online (I'm having trouble following ...
5
votes
4answers
86 views

Find top two clothing sizes in the array

I was recently asked this question in an interview. Here is the solution I came up with. Please let know if I could have done this differently or in a more efficient manner. The question is as ...
1
vote
1answer
38 views

Find the highest result between two elements in an array using their values and indices

I got a programming question on an interview where performance was the focus. I couldnt come up with a better solution than the one below which I think has a time complexity of O(n^2 + n) and scored ...
0
votes
1answer
60 views

Find first repeating Char in String

Given a string, find the first repeating character in it. Examples: firstUnique("Vikrant")None ...
0
votes
2answers
30 views

Expand spreadsheet ranges to lists of cells in Scala

Problem Spreadsheet cells are referenced by column and row identifiers. Columns are labeled with alphabetical characters, starting with "A", "B", "C", ...; rows are numbered from 1 in ascending ...
0
votes
1answer
47 views

Minimum steps to reach target by a Knight In Scala

Given a chessboard of N size (square matrix), the position of Knight and position of a target, find out minimum steps (both count and exact steps) from start to target for a Knight. If it is not ...
5
votes
3answers
137 views

LeetCode 189 - Rotate Array

I have a working solution for this problem that was accepted in LeetCode: Given an array, rotate the array to the right by k steps, where k is non-negative." ...
1
vote
0answers
27 views

Closest 3Sum in Scala

This question is taken from Leet code. Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three ...
4
votes
2answers
34 views

Replace array element with multiplication of neighbors in Scala

Given an array of integers, update the index with multiplication of previous and next integers, Input: 2 , 3, 4, 5, 6 Output: 2*3, 2*4, 3*5, 4*6, 5*6 Following ...
0
votes
1answer
28 views

Clockwise rotate a matrix in Scala

Given a matrix, clockwise rotate elements in it. Examples: ...
1
vote
2answers
35 views

Print matrix in spiral order in Scala

Problem: Given a square or rectangular matrix, print its element in spiral order. For example, if input matrix is this: ...
0
votes
1answer
36 views

Print words in decreasing order of frequency in Scala

Given a string print its words in decreasing order of frequency. Example: i/p - "aa bbb ccc aa ddd aa ccc" o/p - aa,ccc,ddd,bbb Scala: ...
1
vote
2answers
43 views

List of Happy Numbers in scala

Definition of Happy numbers taken from Wikipedia. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits ...
7
votes
2answers
128 views

Calculate the score of a bowling game

Before a job interview, I was asked to create a program that can calculate the score of a bowling game. The full assignment and my code can be viewed on my Github. The company told me that this was ...
6
votes
3answers
188 views

Function to return subword of a camelcase string

Given a camelcase string and an index, return the subword of the string that includes that index, e.g.: ...
0
votes
1answer
42 views

Custom indexOf for strings javascript with regex

I was wondering how efficient my code is creating custom indexOf for strings in JavaScript using regex instead of looping with a for statement the whole way in most ...
2
votes
0answers
39 views

Implementing key map with expire and size limit

Recently I have been asked to implement a key map with expire time for each key and possibility to limit the number of keys, in Python. I've used a dictionary + heap to store the entries, e.g.: ...
1
vote
1answer
48 views

Calculate simple arithmetic string in Scala

Problem Given an arithmetic string like 2+2*3 calculate result 8. Assumptions you can make string will be always well formed (no error checking needs to be done) only operators passed in string ...
1
vote
0answers
47 views

Symfony controller to register and activate users

I've been in an interview some time ago. They objected my Symfony API code with following line: Too much code in controller actions. Can be moved to services to keep the business logic apart ...
0
votes
1answer
33 views

find if one string is a valid anagram of another , in scala

Question is taken from leet code. Problem Given two strings s and t , write a function to determine if t is an anagram of s. Examples ...
1
vote
1answer
48 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 ...
2
votes
2answers
109 views

Find kth smallest element in binary search tree

I was faced with below interview question today and I came up with below solution but somehow interviewer was not happy. I am not sure why.. Given a binary search tree, find the kth smallest ...
3
votes
2answers
60 views

Expressing positive integers as the sum of different charming numbers

In a practice academic interview of mine, we discussed question six, round one, of the United Kingdom Mathematics Trust's 2015 British Mathematical Olympiad. Which states: A positive integer is ...
1
vote
1answer
100 views

Hashing interview puzzle

I've stumbled upon this pretty old article about a hashing interview question, and here it is converted to Swift in a more generic way: ...
5
votes
1answer
582 views

Find the smallest positive number missing from an unsorted array

this is the original question https://www.geeksforgeeks.org/find-the-smallest-positive-number-missing-from-an-unsorted-array/ You are given an unsorted array with both positive and negative elements....
2
votes
1answer
54 views

Map Character to Characters Most Frequently Found With it (in list of strings)

For an interview, I was tasked with writing a program that consumes a list of strings, and produces a mapping between every character in the list, and the characters found most frequently with it (let'...
1
vote
2answers
133 views

String Compression

Implement a method to perform basic string compression using the counts of repeated characters. For example, the string "aabcccccaaa" would become "a2b1c5a3". If the "compressed" string ...
1
vote
0answers
657 views

Find the shortest path between two points in a 2D matrix with obstacles

I need to find shortest path between two points in a grid given an obstacles.. Given a 2 dimensional matrix where some of the elements are filled with 1 and rest of the elements are filled. Here ...
14
votes
4answers
775 views

String Encoder with lower-case output

Question: Take an input string and output the "encoded" string by using the following rules: ...
1
vote
2answers
90 views

HashMap implementation, is this good enough for interviews?

After understanding HashMaps, I decided to implement my own using 3 classes HashMap, LinkedList, and Node. I knew how to implement LinkedList from before. Can you please give me feedback on this. ...
3
votes
1answer
73 views

Find contiguous integers with a given sum

Introduction This question was asked in a technical interview, I am looking for some feedback on my solution. Given a list of integers and a number K, return which contiguous elements of the list ...
2
votes
1answer
44 views

Leetcode #826. Most Profit Assigning Work solution in Java (Sort + Binary Search)

Problem Statement: We have jobs: difficulty[i] is the difficulty of the ith job, and profit[i] is the profit of the ith job....
1
vote
1answer
52 views

Check if list contains a pair which adds up to a given sum

Kindly review this scala code for given problem and suggest improvements. Problem - Given an array of integers and a target sum, check if array contains a pair which adds up to sum. Example - <...