Tiktok University Grad OA 10/17
Anonymous User
2217

Q1:
a) What does Java GC do?
b) Some HTTP question RESTful services. Not even sure. I think this is the answer:
POST is the only RESTful API HTTP method that primarily operates on resource collections.

Q2: Find minimum sum of the array with unique digits.
If there is a duplicate digit, increment until it is unique. NOTE: You can only increment - which actually makes it easier
Used a HashMap and checked for every num + 1 number until I found a false containsKey.

Q3: Paths in a Grid - Well known Hackerrank
Find how many paths from (0, 0) to (n, m) - n and m are parameters.
Passed 7/12 cases TLE :(
I forgot the optimization on this one, but did BFS.

EDIT: found lc problem
https://leetcode.com/problems/unique-paths/
Not exact, in this one u can only go down, but in the real problem, you can only go up (right and up).

Q4: Very complicated... but tbh really easy if you know what they are really asking for
You will be given "connections", Adam follows Becka and Becka follows Chris. There are 3 "nodes" in this social network.
Find the max number of people amongst all social networks.

STDIN:

  1. num. of datasets
  2. num. of connections in each data set
  3. The connections

ex:
1
4
[1, 2]
[1, 5]
[5, 6]
[3, 4]

return 4 because 2 <= 1 => 5 => 6 is the largest social network

My approach:
Use scanner, all inputs are int so using .nextInt() u will know which input is which.
Then make a graph with the connections and find the diameter of the largest graph (run DFS twice)
This works because the forest looks like:
image
(this is actually wrong, this represents my logic while taking the OA)

Basically get the largest tree.
Return number of all the nodes in the largest tree.

TLDR Steps: Decode the input using scanner then do this
https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/

Passed 3/5 cases, TLE

(If you care about my mistake):
I took it as a directed graph. If 1 follows 2 then 1 and 2 are in the same network and we emphasize the connection not who follows who.
So I should have made this an undirected graph: 2 <=> 1 <=> 5 <=> 6.
A test case where it has [6, 5] instead of [5, 6] would fail me because I can in fact go "backwards", but did not account for that.
I may have made other mistakes too tbh, the time complexity was way too high for mine, I was brute checking each node for a connection and adding it to a queue.

Honestly this was much easier than most OAs, I don't see why people said this would be the hardest. Obviously still not going to hear back cuz how horrible I did, but I was able to spot the approach to do the problems (maybe I got better at LC finally?? Nah). I am just a novice, but friends ik would have been able to ace this OA with no pressure. I was the only one in my circle to get this second round of OAs.
I think the hardest one I've taken was HRT lol with 1/4 correct.

Comments (3)