Questions tagged [interview-questions]

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

Filter by
Sorted by
Tagged with
1
vote
0answers
86 views

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 ...
1
vote
0answers
136 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 ...
1
vote
0answers
74 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 ...
1
vote
0answers
240 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 ...
1
vote
0answers
5k 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 ...
1
vote
0answers
64 views

Design a system for renting digital movies/books

During an interview I was asked to do an OO design for a digital renting system for books/movies. This is the design that I came up with. My assumptions: When the customer has downloaded a list of ...
1
vote
2answers
158 views

Greater on the right side in Java

Given an array of integers, replace every element with the next greatest element (greatest element on the right side) in the array. Since there is no element next to the last element, replace it ...
1
vote
0answers
86 views

System on Chip Validator

With reference to my source files, published in the git repository soc-testing I did my best effort at coding, based on 30 years of experience, so I would like to know what I did wrong with my ...
1
vote
3answers
2k views

Reversing the words order of a string

A couple of weeks I had a coding interview and the problem to solve was very simple: reverse the words order of a string. What did I do wrong here? ...
1
vote
0answers
484 views

binary search tree Inorder successor to test candidate confidence

Problem statement Given the root node and a node in the binary search tree, find the inorder successor of the given node. Here is the example of binary search tree, Given the node with value ...
1
vote
0answers
91 views

Implementation of Dequeue data structure

I have just started learning to code for interviews and I would like to request a code review of a "Dequeue" data structure. I could not find any implementation anywhere to compare it to. I would like ...
1
vote
0answers
74 views

Checking whether a directed graph contains a cycle

I create a myGraph class as shown below. Then I created an instance of the graph by giving the adjacency list as a NSDictionary and then call the isGraphCycleFree method. Will this answer look good ...
0
votes
2answers
183 views

Facebook coding interview [closed]

I have joined the Facebook interview recently. And the following question has been asked on the coding interview. ...
0
votes
2answers
6k views

Run-length encoding using C

Recently I was asked in an interview to convert the string say "aabbbccccddddd" to "a2b3c4d5". i.e we have to avoid repeating same character and just adding the repeat count. Here 'a' is repeated ...
0
votes
1answer
79 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 ...
0
votes
2answers
487 views

Google Foobar Challenge: Spy Snippets in Python [closed]

I am getting all the answers correct. But still the solution is not accepted as only 4/5 tests cases are passed. I have not posted the whole problem statement but the problem is similar to this. I ...
0
votes
3answers
1k views

Detecting if two given strings are isomorphic using Java data structures

So I have written the following code and it works for various same length isomorphic strings I have tried. However I am not sure what are some time complexity improvements and coding tweaks that could ...
0
votes
1answer
2k views

Determining whether a string can be rearranged into a palindrome

For a string, count the number of occurences of each character. If at most one character has odd count then the string can be a palindrome else it's not. ...
0
votes
2answers
174 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. ...
0
votes
1answer
215 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: ...
0
votes
2answers
182 views

Design a system for creating a coffeeshop menu

During an interview I was asked to design the menu for a coffee shop employee so that the employee would go and add different items to the menu. This is the design that I came up with. I just want ...
0
votes
2answers
909 views

Spiral printing of 2D matrix

Please comment about code complexity, and coding style, I'm preparing for a code interview, so any comment would be appreciated. Example: Input ...
0
votes
1answer
276 views

Division without using addition, multiplication or division [closed]

Could you please tell me if there is better way of performing division without +, * or /? I'...
0
votes
2answers
4k views

Detect if linked list contains a loop

The following is a code to detect a loop in a linked list. This question is prepared strictly for interview purposes. This code has been modeled as per Linkedlist.java How should I decide if a ...
0
votes
1answer
567 views

C/C++ code to do customized string comparing

It's an interview question, I was asked to compare 2 strings, and the number in the string are evaluated to integers when comparing. I can use C/C++ and can not use stl or stdlib. Some test cases ...
0
votes
2answers
2k views

Count the number of occurences of X's within a range in Java

Given an integer X within the range of 0 to 9, and given two positive integers as upper and lower bounds respectively, find the number of times X occurs as a digit in an integer within the ...
0
votes
3answers
746 views

Calculate median of a matrix

I am solving interview questions from here. Problem : Given a N cross M matrix in which each row is sorted, find the overall median of the matrix. Assume N*M is odd. Note: No extra memory is ...
0
votes
2answers
508 views

Number of Paths (BackTracking) in Java

Illustration You're testing a new driverless car that is located at the Southwest (bottom-left) corner of an n×n grid. The car is supposed to get to the opposite, Northeast (top-right), corner ...
0
votes
2answers
526 views

Pancake sort inteview using java

Given an array of integers arr: Write a function flip(arr, k) that reverses the order of the first k elements in the array <...
0
votes
3answers
532 views

Remove nth node from last position in linked list

Description: Given a linked list, remove the nth node from the end of list and return its head. Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the ...
0
votes
2answers
841 views

Convert NSInteger into NSString

This is my sample code to convert a integer into string. Is it very costly to do the multiple loops of [NSMutableString stringWithFormat:..]? I.e should I just use appendString and get the NSString ...
0
votes
2answers
119 views

Check if path exists directed graph, without using collection

I have written code to find whether the path exists between source and destination in a directed graph. I have used BFS and instead of ArrayList or queue. I have ...
0
votes
1answer
172 views

Displaying information served on the client

I recently did a coding problem for an interview that I unfortunately did not receive the position. So I figured I'd get the code reviewed by other professionals because after asking about the ...
0
votes
1answer
274 views

Insert a digit to maximize the given number

Was asked in an interview today - You are given an integer (in finite range [-N, N]) and you wish to maximize the number by inserting somewhere the digit '5'. My solution - the idea here is going ...
0
votes
1answer
61 views

Choosing between 2 Fibonacci alternatives [closed]

Task: Return the fibonacci value at a given index. e.g: input: 6, return: 8. Algorithm 1: ...
0
votes
1answer
83 views

Find first repeating Char in String

Given a string, find the first repeating character in it. Examples: firstUnique("Vikrant")None ...
0
votes
1answer
317 views

Clockwise rotate a matrix in Scala

Given a matrix, clockwise rotate elements in it. Examples: ...
0
votes
1answer
143 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 ...
0
votes
1answer
84 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 ...
0
votes
1answer
304 views

Reversing the vowels in a String

Given a string, reverse only the vowels present in it and print the resulting string. Input: First line of the input file contains an integer T denoting the number of test ...
0
votes
3answers
1k views

Move last node of the linked list to the front

Description: Given a linked list move the last node to the front. For example: 10 20 30 40 -> 40 10 20 30 Code: ...
0
votes
1answer
69 views

Generate power sets given a set of elements in java

For an array of length n, the possible number of subsets is Math.pow(2, n). for each value between 0 and Math.pow(2, n), see the index at which the bit is set, and include the corresponding number in ...
0
votes
1answer
146 views

Pascal Triangle c# code space complexity

can you give me your impression of my implementation of Pascal triangle problem? I'm especially interested in space complexity evaluation thank you all! ...
0
votes
1answer
191 views

Checking if a number is palindrome or not in Java

Got this question in a technical interview and here is my solution: ...
0
votes
1answer
62 views

Replacing all the 'u' with specific character that is given by the user

I got this question for a Junior Software Developer interview. And came up with this solution in Java: ...
0
votes
2answers
47 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
96 views

Nodejs Interview - API calls and exchange rate

I did an initial technical phone screening with this company which went ok, they then sent me a programming exercise to complete and send back to them. The goal of the exercise: -take input as a ...
0
votes
1answer
474 views

Adding comments to images

I'm working on an interview code sample in Javascript, which is not my first language. The task is simple enough: Given a webpage with a variety of images, allow the users to add comments. The code ...
0
votes
1answer
8k views

Find the intersection of ArrayList elements inside an ArrayList

So the structure is {{Dog,Cat,Human},{Human,Dog,Whale,rabbit,Cow},{Monkey,Human,Dog}}. Output should be: Dog,Human. I have to ...
0
votes
1answer
469 views

Deep copy linked list with a random pointer

I had this as an interview question through phone through an online text editor. The input is a linked list and in addition to a next pointer there is a random pointer that can point to any node ...