Software Engineer Interview Questions
- 0of 0 votes
AnswersYou are in charge of designing a small, in-memory social network, with the basic functionality of adding friendship
- tassecarriere August 26, 2020 in United States
between two people via an AddFriendship function, and a GetSuggestedFriends function for a particular user in the
network. The criteria is to pick someone with whom the given user has the most number of friends in common.
Start by discussing the most suitable data structure, and implement all the objects and functions.| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
Answerstext = 'ABCDEFGHIJ'
- allen zhao August 24, 2020 in United States
output = '"A""| Report Duplicate | Flag | PURGE
Two Sigma Software Engineer Problem Solving - 0of 0 votes
AnswersDesign a system to efficiently find 10 top selling products on an online shopping site at a given time with a time window of say 20 minutes.
- tusharrawat831 July 16, 2020 in India
Say, every second 100 products buy count getting updated.
Which data structure && algorithm would be the best to design such kind of systems ?| Report Duplicate | Flag | PURGE
Accolite software Software Engineer System Design - -1of 1 vote
AnswersGiven an integer array and an integer K, find the number of sub arrays in which all elements are less than K.
- neer.1304 June 01, 2020 in United States
Follow up -
Given an integer array and an integer K, find the number of non overlapping unordered pairs of sub arrays in which all elements are less than K.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 0 votes
AnswersYou are given a series of arithmetic equations as a string, such as:
- manojgct84 May 26, 2020 in India
y = x + 1
5 = x + 3
10 = z + y + 2
The equations use addition only and are separated by newlines. Return a mapping of all variables to their values. If it's not possible, then return null. In this example, you should return:
{
x: 2,
y: 3,
z: 5
}| Report Duplicate | Flag | PURGE
Google Software Engineer Problem Solving - 0of 0 votes
AnswersGiven a board game of N x M size. A domino is of size 1 x 2 and can be rotated to make it 2 x 1. A player can place a domino in any of the available position. When a player is not able to place a domino, he loses. An AI is created to play against the user. The AI selects a random position in the board and places the domino there. Improve this AI. What solution will be the best when board size is small and what if the board size is large.
- komorsad2 April 12, 2020 in India
Anyone has any idea how to have a solution to this problem?| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
AnswersGiving an array of stock prices, find an algorithm of a maximum profit of a series of transactions with a constraint of purchasing one unit at any purchasing transaction.
- fz February 14, 2020 in United States
For example, stock prices
{5, 6, 3, 5, 4, 6, 7}
The transaction sequence would be the following for a maximum profit:
buy on the first day(price 5) and sell on the second day (price 6)
buy on the third day (3) and sell on the 4th day (price 5)
buy on the 5th day and sell on the 7th day (price 7)| Report Duplicate | Flag | PURGE
Software Engineer Algorithm - 0of 0 votes
AnswersGiven a set of integers, the task is to divide it into two sets S1 and S2 such that the absolute difference between their sums is minimum.
- Anon February 09, 2020 in United States
If there is a set S with n elements, then if we assume Subset1 has m elements, Subset2 must have n-m elements and the value of abs(sum(Subset1) – sum(Subset2)) should be minimum.| Report Duplicate | Flag | PURGE
Salesforce Software Engineer - -1of 1 vote
AnswersGiven an array of sets find the one that does not belong:
- billybill January 03, 2020 in United States
example: [[a,b,c,d], [a,b,f,g], [a,b,h,i], [j,k,l,m]]
output: [j,k,l,m]
We can see above that the first three sets have a subset [a,b,c] and the last one does not. Note: There may be a case where the outlier set does have elements contained in the input group. In this case we have the find the set that has the least in common with the other sets.| Report Duplicate | Flag | PURGE
Google Software Engineer Sets - 0of 0 votes
AnswersQ. find the number of ways a string can be formed from a matrix of characters.
- tusharrawat831 December 29, 2019 in United States
It can start forming a word from any position in mat[i][j] and can go in any unvisited direction from the 8 directions available across every cell [i][j].
sample case :
input:
N = 3 (length of string)
string = fit
matrix :
fitptoke
orliguek
ifefunef
tforitis
output: 5
explanation:
num of ways to make 'fit' from matrix chars are 5 as given below sequence:
(0,0) (0,1)(0,2)
(2,1) (2,0)(3,0)
(2,3) (1,3)(0,4)
(3,1) (2,0)(3,0)
(2,3) (3,4)(3,5)
How can we solve it efficiently without doing DFS across every position [i][j], which makes time complexity exponential?
Is there a better way possible in terms of time complexity? Maybe caching of values or something!| Report Duplicate | Flag | PURGE
Software Engineer Algorithm - 1of 1 vote
AnswersWhat to do when we are poor on coding
- shekharlevadi100 December 21, 2019 in India| Report Duplicate | Flag | PURGE
Accenture Software Engineer Coding - 1of 1 vote
AnswersClass A has two data members which are instances of class B and class C. Class B needs an instance of class C to be created. We have to create an instance of object A on stack like 'A objA' in main function. 'new' operator should not be used anywhere.no objects on the heap
- vijay8836 December 18, 2019 in United States| Report Duplicate | Flag | PURGE
Adobe Software Engineer C++ - 2of 2 votes
AnswersGiven a list of 2d points, if any two points have distance(straight line) <= k , group them together. For example. [P1,P2,P3], P1 to P2 <=k, P2 to p3<=k, p1 to p3>k. they are still in the same group. (distance relationship is chainable ) ask how many groups can you find ? I can think of N^2 time complexity with union and find. but how to do better than that? maybe NlogN or O(N)?
- laoen November 30, 2019 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - -1of 1 vote
Answersreverse an array for k distance.
- 786.senthil November 15, 2019 in United States
[2,3,1,5,4] and k =3
output : [2,3,1,5,4]
method
void reverse(int[] arr, k)
this method will only reverse the array
write another method which will sort the array by incorporating reverse method inside sort.
You must have to call reverse(arr,k) method to sort the array. You are not allowed to modify the reverse method| Report Duplicate | Flag | PURGE
Facebook Software Engineer - -2of 2 votes
AnswersGiving a the following:
- xi.text.xi October 22, 2019 in United States for none
A list of a store items T={t_1, t_2,...,t_n}.
A list of prices of each item P={p_1, p_2,...,p_n}.
A list of quantities of each item Q={q_1, q_2,...,q_n}, respectively.
And total bill M.
Our goal is to find any possible list of items that its total value is equal to M using dynamic problem.
Write down a recursive solution.| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - -1of 1 vote
AnswersGiven a set of horizontal and vertical line segments, find the number of squares formed by them?
- uj.us October 04, 2019 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer - 2of 2 votes
AnswersDesign a voting system. 100M users will be logging in within a window of 24h (not necessarily uniformly). Every user will be able to choose from a fixed list of options. If the user has already voted the system should not let them to vote a second time. Additional constraint: only the first 100K votes are accepted. If the quota is exceeded any attempt to vote should be rejected.
- adr September 12, 2019 in United States| Report Duplicate | Flag | PURGE
Software Engineer System Design - 2of 2 votes
AnswersA mobile phone company wants to deploy network of cell towers to provide good signal coverage for its customers. But it doesn't want to have too many towers because they can interfere with one another. All towers are laid out over a 2-dimensional surface and that towers have same sized circular signal zone. You can determine whether their signal zones will overlap in 0 1) time. Give a parallel algorithm for choosing maximal subset of towers that cover non-overlapping areas.
- MaryJane August 19, 2019 in United States
I was not sure if this can be solved using DP?| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
AnswersImplement a comparator class that is capable of sorting by multiple key/order pairs, each pair being a tiebreaker for the previous.
- neer.1304 July 28, 2019 in United States| Report Duplicate | Flag | PURGE
Stripe Software Engineer Object Oriented Design - 0of 0 votes
AnswersYou're running a pool of servers where the servers are
- neer.1304 July 28, 2019 in United States
numbered sequentially starting from 1. Over time, any
given server might explode, in which case its server
number is made available for reuse. When a new
server is launched, it should be given the lowest available number.
Write a function which, given the list of currently
allocated server numbers, returns the number of the next server to allocate.
For example, your function should behave something like the following:
>> next_server_number([5, 3, 1])
2
>> next_server_number([5, 4, 1, 2])
3
>> next_server_number([3, 2, 1])
4
>> next_server_number([2, 3])
1
>> next_server_number([])
1
Server names consist of an alphabetic host type (e.g. "apibox") concatenated with the server number,
with server numbers allocated as before (so "apibox1",
"apibox2", etc. are valid hostnames).
Write a name tracking class with two operations,
allocate(host_type) and deallocate(hostname).
The former should reserve and return the next
available hostname, while the latter should release
that hostname back into the pool.
# For example:
#
# >> tracker = Tracker.new()
# >> tracker.allocate("apibox")
# "apibox1"
# >> tracker.allocate("apibox")
# "apibox2"
# >> tracker.deallocate("apibox1")
# nil
# >> tracker.allocate("apibox")
# "apibox1"
# >> tracker.allocate("sitebox")
# "sitebox1"| Report Duplicate | Flag | PURGE
Stripe Software Engineer Algorithm - 0of 0 votes
AnswersWrite a map implementation with a get function that lets you retrieve the value of a key at a particular time.
- neer.1304 July 28, 2019 in United States
t:0 A =1
t:2 A = 2
get(A, t:1) -> 1
get(A, t:3) -> 2| Report Duplicate | Flag | PURGE
Stripe Software Engineer Algorithm - 1of 1 vote
AnswersCard Game
- acoding167 July 12, 2019 in United States
Card game rule: the hand is drawn from a pack of cards (no jokers).
Play cards ONLY when they are
1. 3 of a kind ('AAA' ) or 4 of a kind('AAAA’).
2. a straight flush of 3 or more cards('JQK' or 'A23456...' in the same suit).
Find out whether the player is able to play the whole hand given.
e.g. [Spade A, Spade K, Spade Q, Diamond Q, Heart Q] return false.
[Spade A, Spade K, Spade Q, Diamond Q, Heart Q, Club Q] return true.| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
AnswersImplement a function which accepts a number and returns top 10 big numbers the function is called with so far;
- vasa.v03 July 10, 2019 in India
If we call the function with 1.. to 100 , for the call function(100) the function will return 91 to 100 in reverse order since they are top 10 biggest number so far| Report Duplicate | Flag | PURGE
British Telecom Software Engineer Algorithm - 1of 1 vote
AnswersGiven a list L of video names and their watch rates, write a function that will return the videos with the top 10 watch rates. Video names may appear more than once.
- neer.1304 July 03, 2019 in United States
Example:
L = [(‘abc’, 10), (‘def’, 15), (‘ghi’, 10), (‘abc’, 12), …, (‘xyz’, 100)]
The function should return [‘xyz’, ‘abc’, …, ‘def’, ‘ghi’]| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersWrite a function that takes a list L and returns a random sublist of size N of that list. Assume that the indexes must be in increasing order. That is, you cannot go backwards.
- neer.1304 July 03, 2019 in United States
Example:
L = [1, 2, 3, 4, 5]
N = 3
The function should return one of these lists:
[1, 2, 3]
[1, 2, 4]
[1, 2, 5]
[1, 3, 4]
[1, 3, 5]
[1, 4, 5]
[2, 3, 4]
[2, 3, 5]
[2, 4, 5]
[3, 4, 5]| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersConsider an undirected tree with N nodes, numbered from 1 to N. Each node has a label associated with it, which is an integer value. Different nodes can have the same label. Write a function that, given a zero indexed array A of length N, where A[j] is the label value of the (j + 1)-th node in the tree and a zero-indexed array E of length K = (N – 1) * 2 in which the edges of the tree are described, returns the length of the longest path such that all the nodes on that path have the same label. The length is the number of edges in that path.
- neer.1304 July 03, 2019 in United States
Example:
A = [1, 1, 1, 2, 2]
E = [1, 2, 1, 3, 2, 4, 2, 5]
This tree is shown below. A node follows the form label, value.
----------1, 1
-----1, 2 1, 3
2, 4 2, 5
The function should return 2, because the longest path is 2->1->3, and there are 2 edges in this path.
Assume that 1 <= N <= 1000 and each element of the array A is an integer in the range [1, 1000000000].| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersGiven a string A consisting of n characters and a string B consisting of m characters, write a function that will return the number of times A must be stated such that B is a substring of the repeated A. If B can never be a substring, return -1.
- neer.1304 July 03, 2019 in United States
Example:
A = ‘abcd’
B = ‘cdabcdab’
The function should return 3 because after stating A 3 times, getting ‘abcdabcdabcd’, B is now a substring of A.
You can assume that n and m are integers in the range [1, 1000].| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersGiven 1-D list of co-ordinates determine if interval (a,b) is covered
- neer.1304 July 03, 2019 in United States
Ex - [(2,5), (5,7),(1,4)] and interval = (1,6)
return true
Explanation - Points 1 to 6 lies in list of interval given 1 to 4. 2 to 5 and 5 to 7.
[(1,4),(6,7),(2,5)] and interval - (1,6)
return false
Explanation - Distance between 5 to 6 is not covered in the list given so return false| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswerCompare two documents(string array) based on n grams.
- neer.1304 July 03, 2019 in United States
e.g doc1 – Today is Sunday.
doc2 – Today is Saturday
if n = 2 then number of duplicates is 1 (Today is)
if n = 1 then number of duplicates is (Today, is)
if n = 3 duplicates is 0| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm
Open Chat in New Window