Pythonphone screen python· L42025
Write a function that inverts a dictionary, mapping each value to the list of keys that had that value
Write a function invert_dict(d) that takes a dictionary where all values are hashable (strings, ints, tuples, etc.) and returns a new dictionary mapping each original value to a sorted list of all keys that mapped to it.
Example:
d = {'a': 1, 'b': 2, 'c': 1, 'd': 3, 'e': 2}
Output: {1: ['a', 'c'], 2: ['b', 'e'], 3: ['d']}
d = {'x': 'hello', 'y': 'hello', 'z': 'world'}
Output: {'hello': ['x', 'y'], 'world': ['z']}
d = {}
Output: {}
Edge cases: empty dict, all keys mapping to the same value, values that are already unique (each list has one element).
SQLphone screen sql· L52025
Find authors who have published at least 5 books
Given a star schema with sales transactions and a book dimensions table, identify all authors who have published at least 5 books.
mixedphone screen sql· unknown2022
Meta | Data Engineer | Phone Interview
Here is my Meta Data Engineer Phone Screen Interview experience (1 hour total- 30 mnts for SQL and 30 Mnts for Python)--Failed\n\n1) I have been asked what section you want to code and i requested for SQL\n Tables names are like. Books , Author , Sales , Cutomer\n\t Book table contains Book name , Author ID , Genre\n\t\t\t\t a) Write a query to print author ID who wrote 5 or more Genres ---Test cases passed\n\t\t\t\t\t \'\'\' select author_id from book\n\t\t\t\t\t\t group by author_id\n\t\t\t\t\t\t having count(author_id) >=5\'\'\n\t\t\t \n\t\tb) Sale table contains ID , tranaction_date ,…
Data Modelingonsite data modeling· L62025
Design a database schema for a ride-sharing service, including tables, field types, and keys
Design a relational database schema for a ride-sharing app. Must specify tables (users, drivers, rides, payments, etc.), field types for each column, primary keys, and foreign key relationships. Discuss one-to-many (driver to rides) and many-to-many (riders to ride requests) relationships, normalization choices, and indexing strategy.
Pythononsite python· L52024
Given a list of log entries with timestamps and event types, compute the count of each event type within each hour
Write a function hourly_event_counts(logs) where each log is a tuple of (timestamp_str, event_type). Timestamps are in 'YYYY-MM-DD HH:MM:SS' format. Return a dictionary where keys are hour strings ('YYYY-MM-DD HH') and values are dictionaries of {event_type: count}.
Example:
logs = [
('2024-03-15 09:12:00', 'click'),
('2024-03-15 09:45:00', 'click'),
('2024-03-15 09:30:00', 'view'),
('2024-03-15 10:05:00', 'click'),
]
Output: {
'2024-03-15 09': {'click': 2, 'view': 1},
'2024-03-15 10': {'click': 1}
}
logs = []
Output: {}
Edge cases: empty log list, logs…
SQLphone screen sql· L52025
Calculate percentage of total sales completed on the same day the customer registered
Given a star schema with sales transactions and customer registration data, calculate the percentage of total sales where the sale was completed on the same day the customer registered.
mixedphone screen sql· unknown2022
Facebook | Data Engineer | Feb- 2022 | Meta | USA | [Waiting for Result]
Company : Facebook | Meta\nPosition : Data Engineer\nLocation : Virginia, USA\nInterview: Virtual Onsite \nYoE: 9+ yrs\n\n**Phone Interview** : \n\nThere was one 1 hr phone interview, there was two section : Algo and SQL \n\nSQL: First I choose to go for SQL , So, my suggestion here: go for the section which you feel more confident, as it will help to boost your confidence and also if you can solve first section little earlier then for second section you can buy some time. \n\nit was having 3 sql question from a given dataset, start with easier to little advance SQL. I nailed it here as I…
Data Modelingonsite data modeling· L62022
Design a data warehouse to combine cellular tower connectivity data with Facebook app logs, including pipeline architecture and dimension/fact schema
Problem Solving round: interviewer sent problem statement 24 hours in advance. FB Connectivity product collects data from cellular towers and marries them to FB app logs to create a data product. Candidate must design: data access strategies, big data processing system components, and the Data Warehouse model. Candidate used Excalidraw to draw architecture. Evaluated on thoroughness of schema design, storage strategy, and system component choices. Virginia USA, 9+ YOE.
Pythononsite python· L52024
Given a list of records with a category and a value, return the top N records per category sorted by value descending
Write a function top_n_per_category(records, n) where each record is a dictionary with 'category' and 'value' keys. Return a dictionary mapping each category to a list of its top n records sorted by value descending. If two records in the same category have equal values, preserve their original relative order.
Example:
records = [
{'category': 'A', 'value': 10},
{'category': 'A', 'value': 30},
{'category': 'B', 'value': 20},
{'category': 'A', 'value': 20},
{'category': 'B', 'value': 50},
{'category': 'B', 'value': 40},
]
top_n_per_category(records, 2)
Output:…
SQLphone screen sql· L52025
Find customers who purchased 3 or more books on both the first and last day of sales
Given sales transactions data, find customers who purchased 3 or more books on both the first day of sales recorded in the dataset AND the last day of sales recorded.