## SDE1 Interview Questions

- 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

- 0of 0 votes
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!

- 0of 0 votes
Given a non-empty string s, you may delete at most k characters. Judge whether you can make it a palindrome.

- 0of 0 votes
Given a dictionary, generate the shortest string, both palindrome and pangram.

Each word can be used only once and unlimited words can be used.

- 1of 1 vote
Give you a pattern (digit in the pattern matches the corresponding

number of letters,

letter means match the letter itself),

a string to determine whether match:

ex:

abc -> 'abc' true

'1oc3' -> 'aoczzz', 'bocabc' true

- 0of 0 votes
assuming there is a freeway, n cars on the road, each car has a different integer speed, but are in the 1-n range. Now give you an array that represents the speed of each car. The starting order of the vehicle is the order of the array, ask the final formation of several clusters, the size of each cluster is how much? It can be understood that, although the vehicle speed is different, but even behind the car faster than the previous car, because you cannot pass, the last must only travel at the speed of the previous car, which formed a cluster. For example [2,4,1,3], finally [2,4] is a cluster, [1,3] is a cluster.

Follow up is now suppose you want to add a car, the speed of the car than other large, but not sure the car's starting order, so that the final output of each possible cluster (List of List). Requirements can be adjusted and call the previous function, but can only be called once

- 0of 0 votes
There is a stream of data <Symbol, timestamp, price>, and possibly also Correction Data <Symbol, timestamp, price> and then addData (symbol, timestamp, price) and correctData , Update minPrice, maxPrice, recentPrice in these two functions.

- 0of 0 votes
Give you a bunch of data <key, value, expiredTime>, design a data structure storage.

About the idea, based on Map solution.

class NewMap {

Map <Integer, Integer> data = new HashMap <> (); // store key-value pairs

Map <Integer, Integer> expired = new HashMap <> (); // store key-expired pairs

}

Then implement the three functions get (), put (), expire ().

- 0of 0 votes
how to implement the standard JSON.stringify and JSON.parse method

- 0of 0 votes
Fibonacci asked if you want to query 1-2 ^ 32 any one but the memory can only remember 2 ^ 20 number of how to do O (1) query

- 0of 0 votes
on a bench, sitting a number of people, and now come up a person, how to find a seat that is farthest from other people,

- 0of 0 votes
0 change to 01,1 change to 10.

Line 0 is 0, the first line is 01, the second line is 0110, the third line 01101001. . . Keep asking what is the vale at kth row and jth col

- 0of 0 votes
Assuming your budget is N, you need to buy a rectangular land. Give a matrix of land prices and ask what is the largest area available for buying land. Land prices must be non-negative. For example, the budget is 11.

`1 2 3 1 0 1 4 2 1 9 10 4 The output should be. 1 2 3 0 1 4`

Such a matrix, because 1 +2 +3 +0 +1 +4 = 11. And the largest area.

- 1of 1 vote
The grid is n by m. Each cell contains a unique number on it. Maga is at the left-top and wants to go to right-bottom. But there is a condition. Maga can go through only two way - right and down. And the path of your move is called the nodes you have passed through over them. The path is called the most beautiful if the following condition is satisfied: The sorted of the path has to be lexicographic smallest as possible as. Output the most beautiful path for given grid.

Input:

In the first line you are given two numbers: the dimensions of grid - n and m. The next n lines contains m numbers. Each number is unique.

Output:

Output the most beautiful path.`4 2 3 1`

Return 1 2 4

There are 2 ways to reach at (2,2) cell. The pathes are 4, 3, 1 or 4, 2, 1 respectively. So The most beautiful of them is 4, 2, 1 because if looking the sorted of them it looks like these : 1, 3, 4 and 1, 2, 4 respectively. So 1, 2, 4 is lexicographic smaller than the other. So the ans is 1 2 4.

- 0of 0 votes
Two binary tree, to determine whether the two trees "similar", similar refers to the corresponding node in each tree in the left child and right child can be the same or in the opposite order, such as the following two trees, D, E where DE And DE can also be DE and ED, BC is the same, but the parent child relationship must be the same.

Followup is if left and right can be the same how to do,`A / \ B C / \ D E A / \ C B / \ D E`

- 0of 0 votes
given n player competition, a bool canbeat (int a, int b) can return a whether beat b. Asked to return a sequence, the sequence only requires two adjacent to the front beat behind. Example, 1 beat 2, 2 beat 3, 3 beat 4, 3 beat 1, 4 beat 1 You can return "1234", that is, although 3,4 can beat 1, but not adjacent does not matter

- 0of 0 votes
Give a two-dimensional array, which represents the value of the jump to the four directions, asked whether from the upper left corner to the lower right corner, follow up the shortest distance

- 0of 0 votes
To A and B two list, B is A shuffle obtained, find the mapping used shuffle,

To be able to handle duplicate elements.

Follow-up: Requirements space O (1),

- 0of 0 votes
list, push is pushed to the head, pop return each element with the same probability. If you push a sorted list into it, how to pop a sorted list out. Follow-up, asked if pop is from head, and push each element with the same probability in any position, how pop a sorted list out?

- 0of 0 votes
Determines whether two strings containing backspace keys are the same.

- 0of 0 votes
A car can receive two instructions A and R. A moves forward for a second and then doubles in speed. R stopped and then reversed. Given a String composed of AR, find where will the car stop.

Follow-up, given the location if the final stop, find the instruction string.

- 0of 0 votes
class EncodingChecker {

EncodingChecker (String pattern) {...} // constructor

boolean isEncoded (String s) {...} // for any string s, check whether s is encoded from pattern, see below

}

pattern = 'abcabc'

s = '123123' -> True

= 'cbzabc' -> False

= 'xyzxyz' -> True

Second question: If the pattern is not one but one million, how to write isEncoded?

- 1of 1 vote
Define a flight class, the flight has four attributes start, end, start time and arrival time,

There is also a list of strings, represents there is a crew member on that site.

given a list of flights, along with the list of strings mentioned above, asking if the flight crew availability is available for all flights.

example: flight 1 {A, B, 3, 10}, flight 2 {A, C, 1, 7}, flight 3 {C, D, 9, 11} crew member list {"A", "A"} Then return true because flight 3 can take off as flight 1 and flight 2 take off first, then flight 2 descends to bring flight crew A to C.

If flight 3 is {C, D, 6, 12} then return false because no flight crew member is in C at time 6.

- 0of 0 votes
Given an array (may have negative num) and an integer(may be negative), find the smallest subarray whose sum is >= the given integer.

int[] nums2 = {5,4,-8,16};

int x=10;

return 1, because 16 >= x

try to solve it in o(n) time

public static int miniSubArrayLen(int[] nums, int s) {