## Recent Interview Questions

- 0of 0 votes

AnswersA Fibonacci sequence is defined recursively by:

- manojgct84 September 17, 2020 in India for Senior Software Engineer

F0 = 0

F1 = 1

Fn = Fn − 1 + Fn − 2, for integer n > 1.

One way of generalizing the Fibonacci sequence is by starting with any pair of numbers and extending to negative values of n.

Given two terms of a generalized Fibonacci sequence Fp and Fq, their positions p and q respectively and a position r, find Fr.

Input Format

The first line of the input contains an integer t denoting the number of test cases.

Each test case contains three lines.

First line of each test case contains two space separated integers p and Fp

Second line contains two space separated integers q and Fq

Third line contains an integer r

Output Format

For each test case, print Fr which is the term of the sequence at position r.

If Fr is not an integer, represent it as an irreducible fraction in the form a/b where b > 0.

Sample Input

0 1

6 13

10

3 65

6 315

-10

0 11

1 -6

2

9 36

15 646

-5

11 72

20 5473

6

Sample Output

89

4620

5

-1/4

13/2| Report Duplicate | Flag | PURGE

Sap Labs Senior Software Development Engineer Java - 0of 0 votes

AnswersCreate a table EMP with the following structure.

- sapavathpavan9 September 16, 2020 in United States

Name Type

EMPNO NUMBER(6)

ENAME VARCHAR2(20)

JOB VARCHAR2(10)

MGR NUMBER(4)

DEPTNO NUMBER(3)

SAL NUMBER(7,2)| Report Duplicate | Flag | PURGE

- 0of 0 votes

AnswersImplement an algorithm that takes in a string containing a parenthesized expression and prints it out with all sibling expressions at the same indent level, each on its own line.

- Priyanka September 14, 2020 in United States

Definitions:

A parenthesized expression consist of an opening parenthesis, one or more expressions separated by one or more spaces, and a closing parenthesis.

An expression is either a word or a parenthesized expression.| Report Duplicate | Flag | PURGE

Snap Inc Software Developer Algorithm - 0of 0 votes

AnswerReinstall AOL Desktop Gold to avoid hitches

- ameliasmith404 September 08, 2020 in United States| Report Duplicate | Flag | PURGE

ABC TECH SUPPORT Consultant - 0of 0 votes

AnswersExamples:

- kamal suthar August 26, 2020 in India

(((abc))) --> abc

(ab(c)) --> ab(c)

(abc09%(c)) --> abc09%(c)

ab(c) --> ab(c)

(ab)c --> (ab)c

abc(c)) → INVALID

(abc)(def) --> (abc)(def)

(abc)typ(def) --> (abc)typ(def)

((abc)(def)) --> (abc)(def)| Report Duplicate | Flag | PURGE

Amazon Computer Scientist Algorithm - 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 - 1of 1 vote

AnswerWrite all possible scenarios for youtube app on your TV

- anonymous August 25, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon Quality Assurance Engineer Quality Assurance - 1of 1 vote

AnswersProgram to find the frequency of each element in the array OR write a program to count the occurrence of each number in a given string

- anonymous August 25, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon Quality Assurance Engineer Coding - 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

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 - 2of 2 votes

AnswersImplement binary addition of two strings.

- fruktoed August 14, 2020 in UK, London

For example "101101" and "111101" equal "1101010"

You cannot use any type conversion, operate only with strings.| Report Duplicate | Flag | PURGE

Facebook Android Engineer Algorithm - 1of 1 vote

AnswerI was asked during a virtual onsite to design a chat server. I was interviewing for a senior software engineer position. Here are some of the requirements:

- codemonkey August 11, 2020 in United States

- real time communication.

- offline handling

- multi-device supports.

Luckily, I was well prepared for system design interview questions. Thanks to system design interview - an insider's guide book on amazon and system design primer. Still waiting for the response. Wish me luck!| Report Duplicate | Flag | PURGE

Google SDE-3 System Design - 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 - 0of 0 votes

AnswersBob and Alice have teamed up on a game show. They won the first

- shashankesh July 23, 2020 in India

round, allowing them access to a maze with hidden gold. If Bob can

collect all the gold coins and deliver them to Alice's position, they can

split the gold. Bob can move North⇆South or East⇆West as long as he

stays in the maze and the cell is not blocked. The task is to determine

the shortest path Bob can follow to collect all gold coins and deliver

them to Alice. If it is not possible, return -1.

You will be given an n × m array where each of the values ∈ {0, 1, 2}

representing open, blocked and open with a gold coin. Alice's position is

given as (x,y) = (row, column). Bob starts at the top left in cell (0, 0).

For example, maze = [[0,2,1],[1,2,0],[1,0,0]] with Alice at (2,2) is

represented as follows:

0 2 1

1 2 0

1 0 0

minMoves has the following parameter(s):

maze[maze[0][0],...maze[n-1][m-1]]: a 2D array of integers

x: an integer denoting Alice's row coordinate

y: an integer denoting Alice's column coordinate

Constraints

1 ≤ n, m ≤ 100

0 ≤ the number of coins ≤ 10

1 ≤ x < n

1 ≤ y < m

The first line contains an integer n, the numbers of rows in maze.

The second line contains an integer m, the number of columns in

maze.

Each of the next n lines contains m space-separated integers

describing the cells of each row in maze.

The next line contains an integer x.

The next line contains an integer, y.

Sample Input 0

3

3

0 2 0

0 0 1

1 1 1

1

1

Sample Output 0

2

Explanation 0

The shortest path Bob can take is (0, 0) → (0, 1) → (1, 1).

Sample Input 1

3

3

0 1 0

1 0 1

0 2 2

1

1

Sample Output 1

-1

Explanation 1

It is not possible for Bob to reach Alice, so we return −1.

Sample Input 2

3

3

0 2 0

1 1 2

1 0 0

2

1

Sample Output 2

5

Explanation 2

The shortest path Bob can take is (0, 0) → (0, 1) → (0, 2) → (1, 2) → (2, 2) → (2, 1).| Report Duplicate | Flag | PURGE

Adobe SDE1 Algorithm - 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 - 0of 0 votes

AnswersGiven a array of integers find the index which partitions the array to two with high numbers and low numbers. For example [5, -1, 3, 8,6] the index 3 will partition the array to [5,-1,3] and [8,6] all the numbers in the second partition are greater than first. The solution has to work in O(n).

- neer.1304 July 15, 2020 in United States| Report Duplicate | Flag | PURGE

Microsoft Algorithm - 0of 0 votes

AnswersGiven an n-ary tree and some queries for the tree, in every query you’ll be given a node you are supposed to print preorder traversal of the subtree rooted at that node.

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 2of 2 votes

AnswersYou have an array of numbers. You have to give the range in which each number is the maximum element. For Example, If array is 1, 5, 4, 3, 6 The output would be

- neer.1304 July 12, 2020 in United States

1 [1, 1]

5 [1, 4]

4 [3, 4]

3 [4, 4]

6 [1, 5]| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswerGiven an array of billion of numbers. Billions of queries are generated with parameters as starting and an ending index. Both these indices lie within that array. Find the maximum number between these two indices in less than O(N)

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersMultiply two numbers without using * and only be using bitwise operations

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersDisplay nodes of a tree in level order using DFS

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersImplement a deque using stacks

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersGiven the entire dictionary of English words, what data structure will you use to efficiently store and match the custom regex string like "D*sk", where * represents any single alphabet, and return the list of matched words?

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswerGiven a skewed tree, an insect is sitting at the root of the tree at t = 0min, every minute insect steps down in the tree, find the probability of the insect being at any node at t = infinity. Once I came up with a solution various other complexities has been added to the problem such as: What if the tree is binary tree (written code for this) What if three is n-ary What if it is now a directed acyclic graph Handle cases that there can be more than one entry point There can be more that one way to reach a node

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersGiven a binary tree of numbers and a search number has given, find out first occurence of that number and smallest distance from root node. if you have given k search numbers find their occurence and nearest from root node in a single walk.

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersGiven a string of numbers put commas so that it become readable like million trillion thousands. eg 1010503 ===> 1,010,503

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersGiven an array of 0s and 1s. find maximum no of consecutive 1s. If you have given chance to flip a bit to 1 such that it maximises the consecutive 1s. find out that flipped bit and after flipping that bit maximum no of consecutive 1s. Above question but you have options to flip k bits.

- neer.1304 July 12, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Algorithm - 0of 0 votes

AnswersDesign a system which will keep track of product and its inventory count. The service will expose two api incrCnt(int prodId, int cnt) and decrCnt(int prodId, int cnt). Which db would you use ? How will you handle hot products ?

- neer.1304 July 01, 2020 in United States| Report Duplicate | Flag | PURGE

Amazon SDE-2 Software Design - 0of 0 votes

Answers/**

- Tekfiesta June 23, 2020 in United States

Given a nested list of integers, return the sum of all integers in the list weighted by their depth.

Each element is either an integer, or a list -- whose elements may also be integers or other lists.

Example 1:

Input: [[1,1],2,[1,1]]. - 1 at depth 2, 1 at depth 2, 2 is at depth 1, 1 at depth2, 1 at depth 2

// [1] - at depth 1, [[1]] - at depth 2, [[[[1]]]] at depth 4

Output: 10

Explanation: Four 1's at depth 2, one 2 at depth 1.

1*2 + 1*2 + 2*1 + 1*2 + 1*2 = 10

Example 2:

Input: [1,[4,[6]]]

Output: 27

Explanation: One 1 at depth 1, one 4 at depth 2, and one 6 at depth 3; 1*1 + 4*2 + 6*3 = 27.

[[[1]]] - at depth 3

*/

/**

* // This is the interface that allows for creating nested lists.

* // You should not implement it, or speculate about its implementation

* public interface NestedInteger {

* // Constructor initializes an empty nested list.

* public NestedInteger();

*

* // Constructor initializes a single integer.

* public NestedInteger(int value);

*

* // @return true if this NestedInteger holds a single integer, rather than a nested list.

* public boolean isInteger();

*

* // @return the single integer that this NestedInteger holds, if it holds a single integer

* // Return null if this NestedInteger holds a nested list

* public Integer getInteger();

*

* // Set this NestedInteger to hold a single integer.

* public void setInteger(int value);

*

* // Set this NestedInteger to hold a nested list and adds a nested integer to it.

* public void add(NestedInteger ni);

*

* // @return the nested list that this NestedInteger holds, if it holds a nested list

* // Return null if this NestedInteger holds a single integer

* public List<NestedInteger> getList();

* }

*/

public int depthSum(List<NestedInteger> nestedList) {

}| Report Duplicate | Flag | PURGE

8x8 Applications Developer Algorithm - 0of 0 votes

Answers Given Two array with the preference of two developers say Ying and Ming, both need to create a team according to the preference, you need to return the String containing the Initial of the team the developers got selected it Note: Ying will always got the chance to make a first pick? {{{Example says Ying Preference table [1,2,3,4] and Ming Preference table is [1,2,3,4] than the Output should be 'YMYM' 2nd Example Ying Preference input array [1,3,2] and Ming Preference input array is [3,1,2] than the String return would be 'YYM'. - sam21088 June 22, 2020 in India for PWM| Report Duplicate | Flag | PURGE

Morgan Stanley Java Developer Algorithm

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window