## Backend Developer Interview Questions

- 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.

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

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

0: A <-> B <-> D

1: C <-> D

give you a start and end, find the path through the least station. followup

Asked the least transfer case

- 0of 0 votes
`Matrix conversion problem. For example, give a matrix a: 1, b: 2. b: 2, c: 3 Then converted into a, b, c 1, 2, . ., 2,3`

- 0of 0 votes
In the range of 0-n, return all the numbers that in the reverse can be mistaken for another number. E.g. 18 -> 81. The corner case is not counting the same number, such as 101 and not 0 at the end of the figure such as 60 (because 09 is not 9)

Public List<Integer> getNum(int n)

- 0of 0 votes
Give a binary tree, each node has an extra information, that is, how many children he has,

Find the kth node val in the inorder transversal ,

Followup how to insert a node, such that this newly added node become the Nth node of the inorder binary tree's traversal`class TreeNode{ int val; int NumberOfchildren; TreeNode left; TreeNode right; public TreeNode(int val){ this.val = val; } } public static int findKthOfInorder(TreeNode root, int k) {`

- 0of 0 votes
Give a string, finds all duplicate substrings of length k

- -2of 2 votes
Give an array such as [1,2,2,2,0] every time you can jump 1 to a [i] step,

If you can jump to 0, return false

if you go out to return true

- 0of 0 votes
A group of people goes to eat together, each pay is not the same, then after they go home later, they each use mutual transfer so that everyone pay the same money.

input is an int array that each person pay, Ask who the amount of money was paid when the transfer was done, such as B -> A $ 3, C -> A $ 1.

- 0of 0 votes
find the last index of the last duplicate number in a sorted array

ex

input: 1,2,5,6,6,7,9

output: 4(index)

- 0of 0 votes
Given a string, check if it is can be reorganized such that the same char is not next to each other, If possible, output a possible result

example

input: google

one possible output: gogole

- 0of 0 votes
Given a binary tree, print the path that has the maximum path sum.

For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need to go through the root. the node val may be negative one`For example: Given the below binary tree, 1 / \ 2 3 Return 2-1-3. -1 / \ -2 3 \ -1 Return 3. public List<Integer> findMaxPath(TreeNode root){ } /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */`

- 0of 0 votes
give a list of cities a to city b the price of air tickets for example

a b 100 $

b c 200 $

e f 200 $

...

Now let you from city x to city y, you cannot transfer more than twice between the two city, find the cheap flight from x to y, follow up print out the flight

- 0of 0 votes
Give a list of the company's Mergers and Acquisitions relationships, for example

[

["baidu", "ofo"],

["mobike", "alibaba"],

]

Said baidu acquired ofo, mobike acquired Alibaba.

Seeking the longest of a M & A chain. No cycle

- 0of 0 votes
Developing Java game

creating a RESTful service using which players can play a simple game described

below.

The game should have the following rules:

• The player has an infinite amount of coins.

• The player bets 10 coins to play a normal game round.

• In any round (free or normal), the player has a 30% chance of winning back 20 coins.

• In any round (free or normal), the player also has a 10% chance of triggering a free round where

the player does not have to pay for bet. The free round works in the same way as a normal round except

it costs 0 coins. The free round should follow immediately after the normal round.

• The player can both win coins and free round at the same time.

- 0of 0 votes
Given a remote having 0-9 digits, plus button (to increase channel), minus (to decrease) and previous channel button (to go to previous channel). We were given 2 numbers stating start and end channel number and an array having various channel numbers. The task was to go to all channel numbers given in array with minimum number of clicks.

- 3of 3 votes
Apple phone interview

Given an API to find all IPv4 addresses in a log file, find all IPs that occurred only once.

Follow-up: What if the log comes from a data stream.

Follow-up: If the machine has 4GB RAM, is there going to be a problem?

- 0of 0 votes
write bash code to determine if the first number in the string is greater than 1000

STR="count ------- 43952 (1 rows)"

- 0of 0 votes
There is 3D space, limited with a cube, with edge=2000.

The center of coordinate system is point (0; 0; 0), so the maximum/minimal coordinate value is 1000/-1000.

There are 10000 points generated with discrete uniform distribution inside of K spheres, located in the cube.

Radius (R) of each sphere is 250.

Centers of spheres are located at the distance of not less than 2*R.

It is required to determine which point related to which sphere.

Input: array of 10000 structures, like:

struct Point {

int number;

int x;

int y;

int z;

}

where number is unique id of the point, x,y,z - it's coordinates.

Output:

array of 10000 structures, like:

struct Point {

int number;

int cluster_id;

}

where cluster_id is unique cluster id of a sphere that point belongs to.

Initially I considered a following solution:

1) Find Euclidian distance for each point from center of coordinates (0;0;0) to point's coordinates.

2) Sort this array of distances in descending order.

3) Get the point from the sorted array of distances and put in a new Set of Cluster Maximals.

4) Compare following point from the array to each value from the Set of Cluster Maximals (initially 1 value).

If it's Euclidian distance less than or equal to 2*R, then

mark this point as belonging to Kth cluster (range=1..N), otherwise add the point to the Set of Cluster Maximals.

5) Repeat step 4.

Two concerns I have:

1) There is an issue that my algorithm would work only in case if Claster Maximals are located on the surface of the spheres.

2) Plus, according to the task requirements, there could be the case when 2 spheres can have 1 and only common point.

I think in case if point belongs to 2 spheres, it is ok to mark it with cluster_id of any of these 2 shperes.

Could you please provide a proper solution to the task?

- 1of 3 votes
Given array of length n, having element 0 to n-1.

you are allowed to swap adjacent element only if Absolute difference of two element is equal to 1.

Is it possible to sort array.

If yes print sorted output.

- -1of 1 vote
--

- 0of 0 votes
1) Given a file containing lines of chars, find if it contains "aaaaab\naaaaa" string pattern. Need to return true only if contains the EXACT pattern specified (observe the new line character).

2) How do you differentiate between actual new line and the new line character?

3) what if the file is way too big to bring it all in memory?

- 2of 2 votes
/**

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

* For example, given the list {{1,1},2,{1,1}} the deepest level is 2. Thus the function should return 8 (four 1's with weight 1, one 2 with weight 2)

* Given the list {1,{4,{6}}} the function should return 17 (one 1 with weight 3, one 4 with weight 2, and one 6 with weight 1)`*/ public int reverseDepthSum (List<NestedInteger> input) { // implementation here }`

- 0of 0 votes
`import java.time.Duration; import java.time.LocalTime; import java.util.List; import java.util.Map; // Your goal is to write business logic for a very simple Restaurant booking system // You are encouraged to refactor exisiting code, create other classes, write helper methods etc // You also need to make sure that the implementation works correctly class Reservation { public String name; public int partySize; public LocalTime startTime; } class Table { public int tableNumber; public int maxPartySize; } class Restaurant { public List<Table> tables; public LocalTime openTime; public LocalTime closeTime; public Map<Integer, Duration> reservationDurationsPerPartySize; // Returns a Table if Reservation could be booked, null otherwise // Booking rules: // 1) Reservation could be made only when the Restaurant is open. // 2) Only one Reservation can be seatted a Table at any time. // 3) Reservation can be seatted only at a Table of the same or a bigger size. // 4) Reservation should stay on the same Table for the whole Duration. // 5) Reservation Duration is determined by PartySize. public Table bookReservation(Reservation reservation) { //TODO: } }`

- 0of 0 votes
Given set of N number of points/Co-ordinates[(x1,y1),(x2,y2), (x3,y3), (x4,y4), (x5,y5), etc] find if any of them form square.

- 0of 0 votes
1) Finish writing the below method: bookReservation(Reservation reservation)

2) You are free to add, modify, etc the following classes and method`import java.time.Duration; import java.time.LocalTime; import java.util.List; import java.util.Map; // Your goal is to write business logic for a very simple Restaurant booking system // You are encouraged to refactor exisiting code, create other classes, write helper methods etc // You also need to make sure that the implementation works correctly class Reservation { public String name; public int partySize; public LocalTime startTime; } class Table { public int tableNumber; public int maxPartySize; } class Restaurant { public List<Table> tables; public LocalTime openTime; public LocalTime closeTime; public Map<Integer, Duration> reservationDurationsPerPartySize; // Returns a Table if Reservation could be booked, null otherwise // Booking rules: // 1) Reservation could be made only when the Restaurant is open. // 2) Only one Reservation can be seatted a Table at any time. // 3) Reservation can be seatted only at a Table of the same or a bigger size. // 4) Reservation should stay on the same Table for the whole Duration. // 5) Reservation Duration is determined by PartySize. public Table bookReservation(Reservation reservation) { //fill this method }`

- 2of 2 votes
Print the longest path from root to leaf in a Binary tree (Basically the nodes that lie on the height path).

- 0of 0 votes
2.{{ Query the sum of all the data values in a given rectangle (x1,y1) ~(x2, y2).

int querySum(int x1, int y1, int x2, y2) {}}}

- 0of 0 votes
{{Given a two dimensional grid that stores data as integers with the size of N*M, implement write and query functions which supports:

1. Write the given value to designated coordination (x, y).

void write(int value, int x, int y) {}

}}

- 0of 0 votes
http://www.buycakeonline.in/corporate-cakes.php