## SDE1 Interview Questions

- 0of 0 votes
Given list of schedules for different flights in a month, determine maximum number of flights that can be in the air anytime in that month.

Input : list of schedules for flights.- spread over a month.

output: a number - maximum flights that can be in the air

Assumptions: 1. All the given times are in a specific timezone( like GMT).

2. Given Schedules can be any time in the month

- 0of 0 votes
To an array and K, each element in the array can only move K positions to the left at most, no limit to the right, try to sort the array under the limit of K

a = [5, 2, 4, 3, 1], k = 2

Return [2, 3, 1, 4, 5]

- 0of 0 votes
Given a function rand32() (random number range 0-2**32-1) that randomly generates a 32-bit int, design a new random function:

Randn(n) generates a random distributed random number (0 - 2**n-1)

Rand3n(n) generates (0 - 3**n-1) the uniformly distributed random number

- 0of 0 votes
Topic: There is a set of coordinates. The original format of each coordinate is (1.3, 0.5). However, the comma and decimal point are gone. Only one string is left, allowing you to restore all possible combinations. For example, 123, possible (1, 23) (1, 2.3) (12, 3) (1.2, 3)

- 0of 0 votes
Implement a method to check if a n-ary tree is unival

class TreeNode {

int val;

List<TreeNode> children;

TreeNode(int val) {

this.val = val;

children = new ArrayList<>();

}

}

- 0of 0 votes
Given the length and width of a rectangle, how many ways can be used to go from the upper left corner to the upper right corner (each step can only go to the right, top right or bottom right):

-follow up 1: If three points in the rectangle must be visited, how many ways

-follow up 2: If you are given an point H, and the path must go down below the H point, how to do it

- 0of 0 votes
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all houses in this place forms an n-nary tree". It will automatically contact the police if two directly-linked houses were broken into on the same night.

Determine the maximum amount of money the thief can rob tonight without alerting the police.

/**

* Definition for a n-ary tree node.

* public class TreeNode {

* int val;

* List<TreeNode> kids;

* }

*/

class Solution {

public int rob(TreeNode root) {

}

}

- 0of 0 votes
preorder Traversing a n-ary tree without using recurrsion

TreeNode<T> {

T val;

List<TreeNode> children;

}

- 0of 0 votes
Given two methods for the person class, one to find a dad and one to find a mother, using these two methods to achieve a method to determine whether the two people are related to blood, assuming a limited number of people.

- 0of 0 votes
Self-implemented data structures and methods, output all the heirs. To achieve birth (parent, name), dead (name), getAllSucession (). There is a king, you can use birth plus children, dead dead. The order of inheritance is the same as preorder except that this tree has multiple children.

- -1of 1 vote
Question 2: Given a number 'k', return the corresponding row, given the pattern:

k => output

0 => []

1 => ["0", "1", "8"]

2 => ["00", "11", "69", "96", "88"]

3 => ["000", "111", "101", "888", ...] // and so on ...

- 0of 0 votes
Question 1: Given an input of an array of string, verify if, turned 180 degrees, it is the "same".

For instance:

[1, 6, 0, 9, 1] => return true

[1, 7, 1] => return false

- 1of 1 vote
Given a binary matrix, find if there is a path from the upper left corner to the lower right corner, meet the conditions each time the value of the cell must be different.

Follow up if there is a path with the same number of 0 and 1?

- 0of 0 votes
There are three threads and we want them to run

one after the other. How can we do that?

- 0of 0 votes
In a grid, you are given a position, and every location has some value.

find the shortest length so that you can touch to any boundary of the grid.

- 0of 0 votes
You are given a graph and an algorithm that can find the shortest

path between any two nodes

Now you have to find the second shortest path between same two nodes.

- 0of 0 votes
Find product of distinct prime

factor of all numbers .

Ex

10

12

7

prime factor of 10 = 2*5

prime factor of 12 = 2*2*3

prime factor of 7 = 7

SO distinct prime factor is 2*5*3*7 = 210

- 0of 0 votes
encode binary in bytes is to give a matrix of size M * N,

This matrix is encoded in bytes as a 4 * 4 bool matrix

[0 0 0 0

1 0 0 1

0 0 0 0

0 0 0 1]

Will be encoded as a byte array [9, 1].

Then write a function set_one (vector <byte> arr, int M, int N, int start_row, int start_col, int end_row, int end_col);

Set all of 0 from (start_row, start_col) to (end_row, end_col) to 1

for example

start_row = 1

start_col = 2

end_row = 2

end_col = 0,

Just that 4 * 4matrix will become

[0 0 0 0

1 0 1 1

1 0 0 0

0 0 0 1]

The byte array after encode should be rewritten as [11, 129].

- 0of 0 votes
find out all of the state machine will guaranteed to come to safe state

ex

A -> [B, C, D, E]

B -> [A]

C -> [D, E]

D -> [E].

E -> [safe state]

Output [C, D, E] because once these states will eventually go to safe state

- 0of 0 votes
Give N socks, there is no guarantee that each can be paired, socks two colors, black and white, you need to pair them

- 0of 0 votes
css color format # abcdef, another abbreviated color format # rgb

(Converted to the previous format, ie, #rrggbb.) Now give your #abcdef, the first color format, to find the two least different colors, #rgb.

- 0of 0 votes
/*Coding question: The customers for a particular business, required to use a webpage to select a Browse Node.

A Browse Node, is an element in the classification structure used to classify products in the Amazon webpage.

The products are classified in 8 categories. Each category has its own sub-classification that looks like a tree with many

children per node and many levels. The UI developer has a tool to paint such tree. He requires from you (You are the backend developer)

to implement 2 interfaces for him:

Node getRoot();

List<Node> getChildren(Node node);

The data is available for you in a text file with this format:

//nodeid, parent_node_id, nodename

Example:

//nodeid, parent_node_id, nodename

10, 1, Comedy Books

20, 2, Tablets

1, -1, Books

11, 1, Novels

12, 11, Terror novels

2, -1, Electronics

-1, 0, GlobalRoot

*/

- 0of 0 votes
A sequence of strings, printed first by column, on a screen of width K,

Requires the first column of the same column by column alignment,

At least one character interval between columns and columns,

Ask how many lines at least?

such as:

The string sequence is {"abc", "de", "fghij", "k", "lmno", "p"}

The screen width is 10

The answer is at least 3 lines

abc k

de lmno

fghij p

- 0of 0 votes
Given list of strings like “ crane, drain, refrain” and a pattern such as *an*

where * can match any number of chracters.

Return the matching word in an efficient manner.

Answer to above question : crane

- 0of 0 votes
Given a string, at each time, you can move any one of the char to the front,

ask you to find the minimum such move to get the target string

example

source abc, target cba :

abc -> bac -> cba

return 2

- 0of 0 votes
Minimum Continuous Subsequence: targetList & availabletTagsList are two lists of string.

Input:

targetList = {"cat", "dog"};

availableTagsList = { "cat", "test", "dog", "get", "spain", "south" };

Output: [0, 2] //'cat' in position 0; 'dog' in position 2

Input:

targetList = {"east", "in", "south"};

availableTagsList = { "east", "test", "east", "in", "east", "get", "spain", "south" };

Output: [2, 6] //'east' in position 2; 'in' in position 3; 'south' in position 6 (east in position 4 is not outputted as it is coming after 'in')

Input:

targetList = {"east", "in", "south"};

availableTagsList = { "east", "test", "south" };

Output: [0] //'in' not present in availableTagsList

Note: targetList will contain Distinct string objects.

- 0of 0 votes
Given one string s1, and then insert one char into this string at any place, to get s2, find the inserted char

Could you do it in logn time

- -1of 1 vote
Given a MxN matrix where each element can either be 0 or 1. We need to print the shortest path between a given source cell to a destination cell. The path can only be created out of a cell if its value is 1.

BFS is trival, please solve it use DFS

public void print(int[][] matrix, int[] start, int[] end){

}

- 0of 0 votes
You are given with a large paragraph and N words.

You have to find a min length subparagraph of the paragraph which contain all those N words in any order. Here length of a paragraph is the count of words in the paragraph.

- -3of 3 votes
Warning! User majia168 is posting fake interview questions!