Meta Phonescreen
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)
Swap Nodes in Pairs
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).
Insert Delete GetRandom O(1)
Implement the RandomizedSet class:
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.