Hi,
I had applied for the SDE-2 role at Databricks using their career portal via LinkedIn and recruiter reached out to after couple of days and scheduled my interviews one by one.
Fibonacci trees are binary trees which are recursively defined as follows:
* T_0 is empty
* T_1 consists of a single node.
* T_n consists of a root node, with T_{n-2} as its left child, and T_{n-1} as its right child.
Examples:
T_0:
T_1:
*
T_2:
*
\
*
T_3:
*
/ \
* *
\
*
Now, in order to be able to identify each node within tree, we enumerated the nodes in each tree using DFS pre-order.
Write a function that given nodes s and e in a Fibonacci tree of order n returns the shortest path from s to e in the form of a sequence of moves: "U" (up), "L" (left), and "R" (right).
Example output:
fibPath(order = 3, start = 1, end = 3) == "URR"
fibPath(order = 4, start = 1, end = 4) == "URL"
fibPath(order = 5, start = 3, end = 7) == "UURLR"Given a set of rules, implement the function access_ok to see if IP address is allowed or denied. Also, print the rules index because of which it is getting allowed or denied. If none of the rules match, deny it.
vector<vector<string>> rules = {
{"ALLOW", "192.168.100.0/24"}, -> 192.168.100.2
{"DENY", "192.168.0.5/30"},
{"ALLOW", "192.168.1.1/22"},
{"ALLOW", "1.0.0.0/8"},
{"ALLOW", "2.3.4.9"},
{"DENY", "8.8.8.8/1"},
{"ALLOW", "5.6.7.8"}
};
access_ok(rules, ip_address) -> true/false
Design Tic Tac Toe
for n * m, matrix and k subsequent tokens
Follow up: is_robot to let AI play randomly You are given an interface StorageClient that allows downloading files from a remote storage system:
getFileSize(uri) → returns the size of the file.
fetch(uri, offset, length, buffer) → fetches length bytes starting at offset into buffer.
Your task is to design a class CachedFile that:
- Downloads a remote file from a given uri with clients calling the CachedFile class with different start and end ranges.
- Optimise the algorithm to supports repeated reads efficiently
- Minimizes repeated network callsVerdict: Pending