Meta Phonescreen
- Posted
- 13 Aug 2025
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.
How it went
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
Questions asked (2)
- 01
Swap Nodes in Pairs
Data Structures & Algorithms · Medium
Open the problemGiven a
headof a linked list, swap every two adjacent nodes and return itshead. I must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed). - 02
Insert Delete GetRandom O(1)
Data Structures & Algorithms · Medium
Open the problemImplement the
RandomizedSetclass:RandomizedSet()Initializes theRandomizedSetobject.bool insert(int val)Inserts an itemvalinto the set if not present. Returnstrueif the item was not present,falseotherwise.bool remove(int val)Removes an itemvalfrom the set if present. Returnstrueif the item was present,falseotherwise.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 averageO(1)time complexity.