Saama Technology Interview Questions
Without using built in functions like Counter , set() , or dict.get() for the core logic: Output: How it works: Iterates through each element in the lis...
Write a script to identify repeated elements from the list and the number of times each is repeated. Without using inbuilt functions. list1 = [2, 3, 4, 3, 10, 3, 5, 6, 3, 3, 31, 10]
Without using built in functions like Counter , set() , or dict.get() for the core logic: Output: How it works: Iterates through each element in the list. Manually checks whether the element already exists as a key in the freq dictionary by looping through existing keys. If found, increments the count; if not, adds it with count 1. Avoids dict.get() , Counter , collections , or set() as instructed. With built ins (for production code):
Write a Scala function using Apache Spark (RDD API) to calculate the total event count on weekdays (Monday to Friday) per month from a given dataset.
Key points: flatMap with Option : Returns Some((month, 1)) for weekdays and None for weekends, effectively filtering in a single pass. reduceByKey : Aggregates counts per month key with a shuffle. Calendar.DAY OF WEEK : Values 2–6 map to Monday–Friday. Error handling : try/catch around date parsing prevents malformed records from crashing the job. In a production setting, prefer DataFrame API with dayofweek() and date format() built in functions for better performance and readability.
What are the differences between using the IN clause and the EXISTS clause with a VALUES table in SQL when filtering records based on a list of IDs?
Both IN and EXISTS filter rows based on a list of values, but they differ in execution strategy, performance, and behavior with NULLs: Syntax comparison: Key differences: IN EXISTS Execution Evaluates the subquery/list fully first, then checks membership Evaluates row by row; stops as soon as a match is found (short circuits) NULL handling IN (1, NULL, 3) — if the column value is NULL, result is UNKNOWN (not TRUE/FALSE), often causing rows to disappear silently EXISTS is unaffected by NULLs in t