Meta Phonescreen

meta logo
meta
August 13, 20255 reads

Summary

I had a phone interview at Meta where I successfully solved two data structure and algorithm problems, and I am currently awaiting a reply.

Full Experience

Had a phone interview 1.https://leetcode.com/problems/swap-nodes-in-pairs/description/ 2.https://leetcode.com/problems/insert-delete-getrandom-o1/

I was able to solve both questions awaiting for reply

Hope this helps for other users

Interview Questions (2)

Q1
Swap Nodes in Pairs
Data Structures & AlgorithmsMedium

Given a head of a linked list, swap every two adjacent nodes and return its head. I must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed).

Q2
Insert Delete GetRandom O(1)
Data Structures & AlgorithmsMedium

Implement the RandomizedSet class:

  • RandomizedSet() Initializes the RandomizedSet object.
  • bool insert(int val) Inserts an item val into the set if not present. Returns true if the item was not present, false otherwise.
  • bool remove(int val) Removes an item val from the set if present. Returns true if the item was present, false otherwise.
  • int getRandom() Returns a random element from the current set of elements (at least one element must exist when this method is called). Each element must have the same probability of being returned. I must implement the functions of the class such that each function works in average O(1) time complexity.
Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!