Software Engineer / Developer Interview Questions
- 0of 0 votes
AnswerLet’s say you are given with n electricity poles in a line. Each pole i has a flexible varying height from 1 to maximum MaxHeight(i) .
- deb~ August 17, 2022 in India
MaxHeights are defined in a separate array MaxHeight[1...n].
These poles can vary their size (expand to max height / shrink to lowest height 1) at any time.
You need to write code to find out the length of wire you would need to connect all these poles from top,
such that no matter how much is the current height of each pole, the wire should be able to connect all these poles from top.
What is the minimum wire length required to sufficiently connect these poles from top in any configurations of poles ?| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 0 votes
AnswerWhat will the following code output
- hr@patelsoft.com April 06, 2022 in India
var hero = {
_name: 'John Doe',
getSecretIdentity: function (){
return this._name;
}
};
var stoleSecretIdentity = hero.getSecretIdentity;
console.log(stoleSecretIdentity());
console.log(hero.getSecretIdentity());| Report Duplicate | Flag | PURGE
patel soft technologies Software Engineer / Developer JavaScript - 0of 0 votes
AnswersWhat will the code below output to the console
- hr@patelsoft.com April 06, 2022 in India
var arr1 = "john".split('');
var arr2 = arr1.reverse();
var arr3 = "jones".split('');
arr2.push(arr3);
console.log("array 1: length=" + arr1.length + " last=" + arr1.slice(-1));
console.log("array 2: length=" + arr2.length + " last=" + arr2.slice(-1));| Report Duplicate | Flag | PURGE
patel soft technologies Software Engineer / Developer JavaScript - 0of 0 votes
AnswersWhat is the output of the following code?
- hr@patelsoft.com April 06, 2022 in India
var length = 10;
function fn() {
console.log(this.length);
}
var obj = {
length: 5,
method: function(fn) {
fn();
arguments[0]();
}
};
obj.method(fn, 1);| Report Duplicate | Flag | PURGE
patel soft technologies Software Engineer / Developer JavaScript - 0of 0 votes
AnswersWhat is the output of below code.
- hr@patelsoft.com April 06, 2022 in India
function checkType(num = 1) {
console.log(typeof num);
}
checkType();
checkType(undefined);
checkType('');
checkType(null);| Report Duplicate | Flag | PURGE
patel soft technologies Software Engineer / Developer JavaScript - 0of 0 votes
Answerswrite a code for lucky sevens using javascript
- hr@patelsoft.com April 06, 2022 in India| Report Duplicate | Flag | PURGE
patel soft technologies Software Engineer / Developer JavaScript - 0of 0 votes
AnswersGive an example of JavaScript Multiplication Table
- hr@patelsoft.com April 06, 2022 in India| Report Duplicate | Flag | PURGE
patel soft technologies Software Engineer / Developer JavaScript - 0of 0 votes
AnswersWhat is the output of below code
- hr@patelsoft.com April 06, 2022 in India
function delay() {
return new Promise(resolve => setTimeout(resolve, 2000));
}
async function delayedLog(item) {
await delay();
console.log(item);
}
async function process(array) {
array.forEach(async (item) => {
await delayedLog(item);
});
console.log('Process completed!');
}
process([1, 2, 3, 5]);| Report Duplicate | Flag | PURGE
patel soft technologies Software Engineer / Developer - 0of 0 votes
AnswersGive an example of JavaScript Multiplication Table
- hr@patelsoft.com April 06, 2022 in India| Report Duplicate | Flag | PURGE
patel soft technologies Software Engineer / Developer JavaScript - 0of 0 votes
AnswersWhat is the output of below code
- hr@patelsoft.com April 06, 2022 in India
const USER = {'age': 30};
USER.age = 25;
console.log(USER.age);| Report Duplicate | Flag | PURGE
patel soft technologies Software Engineer / Developer JavaScript - 0of 0 votes
AnswersWhat are asynchronous thunks
- hr@patelsoft.com April 06, 2022 in India| Report Duplicate | Flag | PURGE
patel soft technologies Software Engineer / Developer JavaScript - 0of 0 votes
AnswersDoes JavaScript supports namespace
- hr@patelsoft.com April 06, 2022 in India| Report Duplicate | Flag | PURGE
patel soft technologies Software Engineer / Developer JavaScript - 0of 0 votes
AnswersCreate a stack for bools. it will have these functions
- milota@mindgrip.com January 28, 2022 in United States
void push(bool input)
bool pop() // no one will ever try to pop if it is empty
bool empty() const // returns true if the stack is empty
void clear() // cleans out the data and recovers the memory
This stack should not be limited in size but grow as needed.
hard part
save space, it is ok if it is slow from time to time but should generally be fast
98% of the time we will push false and 2% of the time we will push true
edge conditions
the first push may be true or false
there may be long runs of just pushing true or long runs of just pushing true
second part
how would you change it to if it was 80 / 20 and there were long runs of an average length of 15 trues in a row?
third part
How would you change it if there were different ratios and different average length runs.| Report Duplicate | Flag | PURGE
Software Engineer / Developer Data Structures - 0of 0 votes
AnswersYou will be given matrix of 0 and 1
- dfsdfdsfd November 28, 2021 in Berling
100
100
if cell with value 0 has at least one 1 from up, down, left or right side then you have to convert this change it to 'b'.
if cell has value 'b' its bin cell
Find clothest distance from every cell to bin cell| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 0 votes
AnswersFinding Amsterdam Stock Exchange
- wanabeunknown November 08, 2021 in Netherlands
Ian and Sylvia are planning a visit to Amsterdam. They want to plan their sight seeing route. Sylvia is reading from the touristic guide and Ian is writing the list with sights.
Sylvia is giving Ian 2 commands:
- Add <sight> -> to add this sight on top of the visiting stack of sights to be planned for visit.
- Remove -> to move the sight on top of the visiting stack in their itinerary.
Ian wants to be able to also add, at the end of the day, a visit to the Amsterdam Stock Exchange Building, as it is the oldest modern exchange in the world, built in 1602.
To be able to do this, he wants to optimize the route that they are planning, without Sylvia's knowledge.
Whenever she is not watching, he can rearrange the stack of sights, so that, if Sylvia is asking to move the top sight to the itinerary, the itinerary list will still have the optimal path.
Tell Ian the minimum number of times he needs to reorder the sights so that he can achieve his goal.
Sights are numbered from 1 to n, in the order of the optimal path that Ian wants to take.
It is guaranteed that a sight will be added, before it is needed for the sight to be moved to the itinerary.
Clarifications Optimal path is the path from 1 n Amsterdam Stock Exchange is considered to be the sight with number n. You have a time limitation of 60 minutes.
Input :
The first line of input contains the integer n (1 <= n <= 10^6) — the number of sights to be planned Each of the next 2n lines of input starts with a string "add" or "remove".
If the line starts with the "add", an integer x (1 <= x <= n) follows, indicating that Ian should add the sight with number x to the top of the stack.
It is guaranteed that exactly n lines contain "add" operations, all the sights added are distinct, and n lines contain "move" operations.
It is also guaranteed that a sight is always added before it is required to be moved.
Output:
Print the minimum number of times Ian needs to reorder the sights to successfully achieve his goal.
Examples:
Input:
3
add 1
remove
add 2
add 3
remove
remove
Output:
should be 1.
Note In the first sample, Ian should reorder the sights after adding sight 3 to the stack.
Input:
7
add 3
add 2
add 1
remove
add 4
remove
remove
remove
add 6
add 7
add 5
remove
remove
remove
For this, output should be 2.
Note: In the second sample, Ian should reorder the sights after adding sight 4 and sight 7 to the stack.| Report Duplicate | Flag | PURGE
Flow Traders Software Engineer / Developer Algorithm - 2of 2 votes
AnswersWhen a person who knows it meets any other person, they immediately share the story with them.
- veeru June 25, 2021 in India
Initially, only person 1 knows the story. Given a list of meetings between people in a form of
(person_1_id, person_2_id, timestamp) construct a list of the persons who will know the story
at the very end.
Example: [(1, 2, 100), (3,4, 200), (1,3, 300), (2,5, 400)], 1 // The events could be out of order.
Person 2 will learn the story at the moment 100, person 3 — at the moment 300,
person 5 — in the moment 400. Person 4 will never learn the story. So the answer is [1, 2, 3, 5].
Eg2: [(1, 2, 100), (2, 3, 100), (4, 5, 100)], 2
where the first parameter is array of the Persons meet at particular timestamp, second parameter is the PersonId who knows the story first.
Output: [1, 2, 3]| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Data Structures - 1of 1 vote
AnswersGiven a string s consisting of items as "*" and closed compartments as an open and close "|", an array of starting indices startIndices, and an array of ending indices endIndices, determine the number of items in closed compartments within the substring between the two indices, inclusive.
- prashant1diwase May 24, 2021 in United States for Tax Systems
An item is represented as an asterisk ('*' = ascii decimal 42)
A compartment is represented as a pair of pipes that may or may not have items between them ('|' = ascii decimal 124).
Example
s = '|**|*|*'
startIndices = [1, 1]
endIndices = [5, 6]
The string has a total of 2 closed compartments, one with 2 items and one with 1 item. For the first pair of indices, (1, 5), the substring is '|**|*'. There are 2 items in a compartment.
For the second pair of indices, (1, 6), the substring is '|**|*|' and there are 2 + 1 = 3 items in compartments.
Both of the answers are returned in an array, [2, 3].
Function Description .
Complete the numberOfItems function in the editor below. The function must return an integer array that contains the results for each of the startIndices[i] and endIndices[i] pairs.
numberOfItems has three parameters:
- s: A string to evaluate
- startIndices: An integer array, the starting indices.
- endIndices: An integer array, the ending indices.
Constraints
1 ≤ m, n ≤ 105
1 ≤ startIndices[i] ≤ endIndices[i] ≤ n
Each character of s is either '*' or '|'
Input Format For Custom Testing
The first line contains a string, s.
The next line contains an integer, n, the number of elements in startIndices.
Each line i of the n subsequent lines (where 1 ≤ i ≤ n) contains an integer, startIndices[i].
The next line repeats the integer, n, the number of elements in endIndices.
Each line i of the n subsequent lines (where 1 ≤ i ≤ n) contains an integer, endIndices[i].
Sample Case 0
Sample Input For Custom Testing
STDIN Function
----- --------
*|*| → s = "*|*|"
1 → startIndices[] size n = 1
1 → startIndices = 1
1 → endIndices[] size n = 1
3 → endIndices = 3
Sample Output
0
Explanation
s = *|*|
n = 1
startIndices = [1]
n = 1
startIndices = [3]
The substring from index = 1 to index = 3 is '*|*'. There is no compartments in this string.
Sample Case 1
Sample Input For Custom Testing
STDIN Function
----- --------
*|*|*| → s = "*|*|*|"
1 → startIndices[] size n = 1
1 → startIndices = 1
1 → endIndices[] size n = 1
6 → endIndices = 6
Sample Output
2
Explanation
s = '*|*|*|'
n = 1
startIndices = [1]
n = 1
endIndices = [6]
The string from index = 1 to index = 6 is '*|*|*|'. There are two compartments in this string at (index = 2, index = 4) and (index = 4, index = 6). There are 2 items between these compartments.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures - 0of 0 votes
AnswersSay that you have p1(Child) - > a & b and p2 (Child) -> c & d. Which return list p1 and p2 child and see p1 and p2 are related. We need to check if they going over the tree.
- Manoj May 08, 2021 in India
Inupt assumption is : p1 -> a & b
p2 -> c & d
a - it own parent & b - it own parent
c - it own parent & d - it own parent and so on.| Report Duplicate | Flag | PURGE
Salesforce Software Engineer / Developer - 3of 3 votes
AnswersAsked in Google - 2020, Goldman Sachs - 2020
- Gaurav Sohaliya August 22, 2020 in India
Given two Array.
A = [1,3,4,2,5,6] B = [3,4,6,5,7]
we have to remove 3,1,2,6 and Insert 6,7 to make A equal to B.
we can delete and insert any element at anywhere from first array and make that array same as second array. Output is Minimum Number of elements required to be insert in first array.
constraints:
1 <= First Array Size <= 10^5
1<= Second Array SIze <= 10^5
1 <= firstarray[i] <= 10^9
1 <= secondarray <= 10^9
second array consist of distinct element.
Note : it is same as edit distance but here our constraints are 10^5.| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer Arrays - 0of 0 votes
Answersfind target in chess board with given start position of knight
- thosh July 31, 2020 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 1of 1 vote
AnswerVERY IMPORTANT C PROGRAMMING QUESTION. PLEASE HELP. DUE DATE: 19.05.2020 21:00 (I HAVE 7 HOURS TO SUBMIT QUESTION)
- eriklisoda May 19, 2020 in United States for Ankara
Your task is to find the given list of words inside a given character grid. The dimensions of the character grid will be 8 x 8. Each cell of the character grid will contain one of the capital letters in the English alphabet.
The inputs of the program will be as follows:
1) First, a 8 x 8 character grid will be given as input where each row will be given in separate lines. Each row of the character grid will be separated from other rows with a newline character ('\n') including the last row.
2) Next, the number of list of words to be found will be given as input in a separate line ending with a newline character.
3) Finally, the list of words to be found inside the character grid will be given as input in separate lines. Each word in the list will be separated from other words with a newline character ('\n') including the last word.
The properties of the character grid and the rules for finding the words are given as follows:
1) The number of list of words may be at least 1 and at most 15.
2) The length of each word in the list of words will be at least 3 and at most 8 characters.
3) Each word in the list of words may be located inside the character grid in any of:
a) horizontal which is left to right,
b) vertical which is up to down,
c) diagonal which either
i) starts at an upper-row-left-column and ends with a lower-row-right-column (e.g. a 3 characters length word "PIE "which starts at (1,2) and ends at (3,4) ),
ii) starts at an upper-row-right-column and ends with a lower-row-left-column (e.g. a 4 characters length word "FEEL" which starts at (2,6) and ends at (5,3) )
directions where each letter that compose that word should be located in the neighboring cells. The directions other than the given above will not be considered while searching any word inside the character grid.
4) When your program finds a word inside the character grid, the letters that compose that word should be substituted with the "#" character.
5) While searching words inside the character grid, you should consider that a character inside the character grid may be reused to find more than 1 word. Check the sample run for a concrete example.
6) All the words in the list of words will be available on the character grid.
7) All the words inside the list of words will be distinct.
8) A word inside the character grid will appear only once in the character grid: It is not possible to find any word more than one location inside the character grid.
9) When the list of words is input by the user, the order of the words IS NOT necessarily an alphabetical order.
10) The word is guaranteed to be found inside the character grid if you search in all (vertical, horizontal or diagonal) directions.
Your program is expected to output the final modified version of the character grid where all the words in the list are substituted with "#" in the character grid and the remaining letters are left as is. Similar to input format, each row of the modified character grid will be printed in distinct rows separated with newline character ('\n') including the last row as output.
Sample Run
----------
Input:
AWESOMEA
DEKTTADR
DZLZQUOC
RPEYRMDL
EEAEAPRY
SFFNQBDA
SSFTMASN
AWESOGER
5
ADDRESS
STUDY
LEAF
ROMAN
AWESOME
Output:
#######A
#EKT#AD#
#Z#ZQ##C
#P#YR##L
#E#E#PR#
#F##QBDA
#SFTMASN
AWESOGER
Explanation of Sample Run:
The following character grid is input by the user:
AWESOMEA
DEKTTADR
DZLZQUOC
RPEYRMDL
EEAEAPRY
SFFNQBDA
SSFTMASN
AWESOGER
The number of list of words is 5
The list of words are:
ADDRESS
STUDY
LEAF
ROMAN
AWESOME
The row and column numbers of the character grid are written below to follow the explanations, clearly.
0 1 2 3 4 5 6 7
0 A W E S O M E A
1 D E K T T A D R
2 D Z L Z Q U O C
3 R P E Y R M D L
4 E E A E A P R Y
5 S F F N Q B D A
6 S S F T M A S N
7 A W E S O G E R
1. The letters of "ADDRESS" are found in the zeroth to the sixth row, all in column 0. These letters are substituted with the "#" character. Then, the modified character grid becomes as follows:
#WESOMEA
#EKTTADR
#ZLZQUOC
#PEYRMDL
#EAEAPRY
#FFNQBDA
#SFTMASN
AWESOGER
2. The letters of "STUDY" are found in the diagonal of (0,3),(1,4),(2,5),(3,6),(4,7) where the numbers in the parenthesis represent (row, column) numbers, respectively. These letters are substituted with the "#" character. Then, the modified character grid becomes as follows:
#WE#OMEA
#EKT#ADR
#ZLZQ#OC
#PEYRM#L
#EAEAPR#
#FFNQBDA
#SFTMASN
AWESOGER
3. The letters of "LEAF" are found in the second to the fifth row, all in column 2. These letters are substituted with the "#" character. Then, the modified character grid becomes as follows:
#WE#OMEA
#EKT#ADR
#Z#ZQ#OC
#P#YRM#L
#E#EAPR#
#F#NQBDA
#SFTMASN
AWESOGER
4. The letters of "ROMAN" are found in the diagonal of (1,7),(2,6),(3,5),(4,4),(5,3) where the numbers in the parenthesis represent (row, column) numbers, respectively. These letters are substituted with the "#" character. Then, the modified character grid becomes as follows:
#WE#OMEA
#EKT#AD#
#Z#ZQ##C
#P#YR##L
#E#E#PR#
#F##QBDA
#SFTMASN
AWESOGER
5. The letters of "AWESOME" are found in the zeroth to sixth column, all in row 0. These letters are substituted with "#" character. Notice that 'S' in row 0 is used both for the words "AWESOME" and "STUDY". Also, 'A' at (0,0) is used both for the words "ADDRESS "and "AWESOME". Since there are 5 words, there is no word remaining to find in the character grid. Hence, your program should print the final version of the grid given below on the screen, where each row will be separated with a newline character ('\n') including the last row.
#######A
#EKT#AD#
#Z#ZQ##C
#P#YR##L
#E#E#PR#
#F##QBDA
#SFTMASN
AWESOGER| Report Duplicate | Flag | PURGE
Software Engineer / Developer - 0of 0 votes
AnswersDescribe the Flyweight and Visitor design pattern with example
- bharsaklemukesh975 September 22, 2019 in India| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer / Developer Object Oriented Design - 0of 0 votes
AnswersYou have a vector of 128 floats (float data[128]) in shared memory, an environment with 8 threads and a convenient function called barrier() that will block on each thread until it will be signaled by all 8 threads (a simple semaphore of 8 elements).
- bharsaklemukesh975 September 22, 2019 in India
Write a pseudo-C parallel function that calculates the sum of all 128 elements storing it inside data[0]; the function can alter/destroy the content of the other 127 elements of data[].
thread_id goes from 0 to 7: it is constant and unique for each of the 8 threads.| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer / Developer Operating System - 0of 0 votes
AnswersConsider the following 3D scene representing an old town's main square:
- bharsaklemukesh975 September 22, 2019 in India
• A single statue
o static geometry, high polygon count
o low complexity fragment shader
• A particle system simulating smoke
o animated, rendered as a large set of points
• A small set of characters
o animated geometry, medium polygon count
o medium complexity fragment shader
• A large set of buildings
o static geometry, low polygon count
o low complexity fragment shader
• A background image/skybox
• The camera/viewpoint is continuously moving within the scene.
How would you render the statue - by itself – using OpenGL to achieve maximum vertex performance (vertices/second)?
How would you render the particle system - by itself - using OpenGL to achieve maximum vertex performance (vertices/second)?
How would you render the scene - as a whole - most efficiently on a GPU using OpenGL?
Given that the 3D scene was being rendered correctly but that you wanted to improve the performance further, how would you determine if the main performance limitation/bottleneck was located in the application, in the vertex processing stage, or in the fragment processing stage?| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer / Developer Graphics - 0of 0 votes
AnswersImplement auto complete for IDE, you will be given strings of classes and input, input can be like MVC, MoClick, MouseClickHand
- neer.1304 August 17, 2019 in United States
For MouseClickH => MouseClickHandler
MVC => can match to any classes where first word starts from M then V then C| Report Duplicate | Flag | PURGE
Pinterest Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou are given a list of edges in a graph and for each pair of vertices that are connected by an edge, there are two edges between them, one curved edge and one straight edge i.e. the tuple (x, y, w1, w2) means that between vertices x and y, there is a straight edge with weight w1 and a curved edge with weight w2. You are given two vertices a and b and you have to go from a to b through a series of edges such that in the entire path you can use at most 1 curved edge. Your task is to find the shortest path from a to b satisfying the above condition.
- Rising star August 07, 2019 in India| Report Duplicate | Flag | PURGE
Uber Software Engineer / Developer Algorithm - 0of 0 votes
AnswerYou are given a n x m grid consisting of values 0 and 1. A value of 1 means that you can enter that cell and 0 implies that entry to that cell is not allowed. You start at the upper-left corner of the grid (1, 1) and you have to reach the bottom-right corner (n, m) such that you can only move in the right or down direction from every cell. Your task is to calculate the total number of ways of reaching the target.
- Rising star August 07, 2019 in India
Constraints :-
1<=n, m<=10, 000| Report Duplicate | Flag | PURGE
Uber Software Engineer / Developer Algorithm - 0of 0 votes
AnswerThere is a meeting scheduled in an office that lasts for time t and starts at time 0. In between the meeting there are n presentations whose start and end times are given i.e. the ith presentation starts at s[i] and ends at e[i]-1. The presentations do not overlap with each other. You are given k, the maximum number of presentations that you can reschedule keeping the original order intact. Note that the duration of the presentation can't be changed. You can only change the start and end time. Your task is to maximize the longest time period in which there is no presentation scheduled during the meeting.
- Rising star August 07, 2019 in India
Constraints :-
1<=t<=1, 000, 000, 000
0<=k<=n
1<=n<=100, 000
e[i]<=s[i+1], 0<=i <n-1
s[i] < e[i] for 0<=i<=n-1| Report Duplicate | Flag | PURGE
Uber Software Engineer / Developer Algorithm - 1of 1 vote
Answers// For a given vector of integers and integer K, find the number of non-empty subsets S such that min(S) + max(S) <= K
- samayragoyal990 February 24, 2019 in United States
// For example, for K = 8 and vector [2, 4, 5, 7], the solution is 5 ([2], [4], [2, 4], [2, 4, 5], [2, 5])
The time complexity should be O(n2). Approach and code was asked| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer