## Backend Developer Interview Questions

- 0of 0 votes
Count maximum number of pair (a, b) possible from an array so that a is less than equal to 2*b. Also tell number of unpaired element left.

So for Input

1, 3, 5, 6, 7

ans = 2 1

- 0of 0 votes
An array is special if it contains special elements. A special element is an element which can be represented by the sum of two numbers where one number is reverse of other. Like Array is {22, 121} . Here 22 = 11 + 11 and 121 = 92 + 29. Hence both elements are special. The input array is an array of strings. Output number of special elements in the array.

- 0of 0 votes
How would you design a system where you have 1000 records in database and on UI you are showing them, a user can select single or bulk record which can be in any order and drag drop to reorder the sequence of the record. Example :

I have below records

1

2

3

4

5

a user selects 1 and dragdrops it on 5th position, so the new order becomes 2,3,4,5,1. This has to be done at the database layer and in efficient way. How to maintain continuous reordering sequence of records?

- 0of 0 votes
Given lat long of cabs in a city(lat long keeps changing)

Implement a function getNearby(lat1,long1) which returns all cabs in a circle of radius R from lat1,long1.

Which datastructure will u use?

FollowUp qs: Hows it implemented using a database like MySQl or Postgres.

- 0of 0 votes
Give me a list of int, find the length of the smallest cycle. For example, 1, 2, 1, 2, the length of the cycle is 2. Then 1, 2, 1, 2, 1 has a minimum length of 2. Then the length of 1, 2, 1, 2, 3 should be 5 because the entire list is not in repeat. Then the minimum length of 1, 2, 1, 2, 1, 1, 2 is 2.

- 0of 0 votes
Find the kth missing element in a sorted array. For example [2,3,5,7], k = 0: return 4, k = 1: return 6

expected time complexity logn

- 1of 1 vote
For two string a, b, their distance is defined as the number of positions at which the corresponding character are different.

Now you can swap characters at any two locations once, and ask how to swap to make the distance the smallest.

- 0of 0 votes
A coffee machine has three buttons (S, M, L). After pressing each button, the coffee machine will flow out of a range of coffee [s1, s2], [m1, m2], [l1, l2], but the outflow of coffee The amount is random. There is a cup with a total capacity of c2. There is a tick c1 on the cup. If the amount of coffee is [c1, c2], it is considered full.

After asking for a series of button operations, can the coffee be filled in [c1, c2] but not overflow?

- 0of 0 votes
Input like method stack trace: "main, start", "foo, start", foo, end", "bar, start", "bar end", "main, end", "main2, start", "main2, end"

Output String, such as the following format, to indicate the order in which the method was called and the hierarchy`main Foo Bar main2`

- 0of 0 votes
turns the following format string into a tree: node has keys, values, and subtrees.

For example, the first key is node1 and the value is ‘aaaa’

<node1>aaaaa<node2>bbbbb</node2><node3>cccc</node3><node4>dddd</node4></node1>

- 0of 0 votes
find longest common suffix of two linked list.

- 0of 0 votes
Give a 0/1 matrix to find and remove the islands. Assume that the boundaries of the matrix are 1

The definition of islands is surrounded by 0

The simplest example is

enter:

111111

100001

100101

100001

111111

Output:

111111

100001

100001

100001

111111

- 0of 0 votes
Write a hash function so that a string and its reverse get the same return value

Hash(‘banana’) == hash(‘ananab’)

Hash(‘banana’) == hash(‘banana’)

Hash(‘banana’) != hash(‘banaaa’)

- 0of 0 votes
x={a,b,c}, y={p,q}, z={r,s}

Define a

Operation, x * y * z = {{a,p,r},{a,p,s},{a,q,r},{a,q,s}......{c,q s}}

Is to output all the results in the order of each subset, implementing a class iterator that has Next() and hasNext() methods

- 0of 0 votes
Give a tree-like graph that lets you find the maximum length from the leaf node to the leaf node. The input is an array of edges.

- -1of 1 vote
To determine whether two people have kinship, all data structures need their own definition

- 0of 0 votes
Given an integer n (say somewhere between 100 and 1000), you want to generate a random binary tree having exactly n nodes. You are only interested in the structure of the tree. Each structurally unique tree should ideally have the same chance of being generated.

- 0of 0 votes
Given k numbers as strings. The numbers may be very large (may not fit in long long int), the task is to find sum of these k numbers.

Example

S1 = “100”

S2 = “10”

S3 = “1”

Return “111”

public string addNumbers(String[] nums){

}

- 0of 0 votes
The problem is to count all the possible paths from any points to bottom right of a mXn matrix with the constraints that from each cell you can either move only to right or down

- 0of 0 votes
Find the final states of a n-nary tree

each node has three states, 0,1,2.

Require that if all child nodes are 2,

The parent node is also 2.

All child nodes are 0, the parent node is 0, and the rest are all 1s.

- 0of 0 votes
Given two functions, start (id, start_time), stop (id, time),

Respectively, to the id assignment start and end time, gave a bunch of such operations (to ensure that the operation start small id first appeared,

And each id last have start_time and stop_time), press the start order to print the corresponding id, start_time, stop_time,

Requirements of space complexity as small as possible,

e.g., start (1, 1), start (2, 2), stop (2, 3), start (3, 4), stop

The print order is (1,1,6), (2,3,2), (3,4,5) # (id, start_time, end_time).

- 0of 0 votes
To several bus lines, each line is a two-way line, such as:

0: A <-> B <-> D

1: C <-> D

After writing the map, give you a start and end, let me find the path through the least station.

- 0of 0 votes
Output the second index corresponding to the first one, requiring output only if there is only one match, and false if there is more than one pair

a b c d e f g a b -> [0,1]

a b b c, a b c -> False

- 0of 0 votes
Check if characters of a given string can be swaped to form target string

ab : ba true

ac : ab false

- 0of 0 votes
`1 \ 2 - 3 \ / 4 | 5 - 8 | / 7 For the undirected graph, the LCS is 2,3,4,5, so how can we find it? For a undirected graph, find the Longest Consecutive Sequence`

/**

* Definition for undirected graph.

* class UndirectedGraphNode {

* int label;

* List<UndirectedGraphNode> neighbors;

* UndirectedGraphNode(int x) { label = x; neighbors = new ArrayList<UndirectedGraphNode>(); }

* };

*/

public class Solution {

public List<Integer> longestGraph(List<UndirectedGraphNode> nodes) {

}

}

- 0of 0 votes
check if there are two subarrays in an array are identical

- 0of 0 votes
comparison of two strings if they are the same, use o(1) space

abc \ b is equal to ab

abc \ ca equals abcA

\ b = backspace

\ c = CapsLock

- 0of 0 votes
convert Prefix to Postfix using recursion

+ * A B / C D -> A B * C D / +

- 0of 0 votes
Given the below input and output and asked to write in Java.

Example 1)

input : {1,2,3,4, &, 12,13,14,15}

output : {15,14,13,12,1,2,3,4}

Example 2 )

input : {33,34,&,55,63}

output : {63,55,33,34}

Assumption : '&' will always be in the middle.

- -1of 1 vote
Find if the shorter string is a subsequence of the longer string

Output the second index corresponding to the first one, requiring output only If there is only one match, and false if there is more than one pair

a b c d e f g, a b -> [0,1]

a b b c, ab c -> False