**Consecutive Days Logins:**Given a table`logins`

with columns`user_id`

and`login_date`

, find users who logged in on two consecutive days.**Users with All Activities:**Given a table`activities`

with columns`user_id`

and`activity`

, find users who have performed all three activities: 'login', 'purchase', and 'logout'.**Ranking Products by Price:**Given a table`products`

with columns`product_id`

and`price`

, rank the products by price without using the`RANK()`

function.**Second Highest Salary:**Given a table`employees`

with columns`employee_id`

and`salary`

, find the second highest salary.**Duplicate Email Addresses:**Given a table`users`

with an`email`

column, find all email addresses that appear more than once.

Please sign-in to view the solution

**SQL Query for Top N Records:**Write an SQL query to fetch the top 5 employees with the highest salaries from an`employees`

table with columns`employee_id`

,`name`

, and`salary`

.**SQL Query for Aggregate Function:**Write an SQL query to find the average salary of employees in each department from a table`employees`

with columns`department_id`

,`employee_id`

, and`salary`

.**Python Function for Factorial:**Write a Python function to compute the factorial of a given number.**Python List Comprehension:**Write a Python one-liner using list comprehension to create a list of squares of the first 10 natural numbers.**Python String Manipulation:**Write a Python function to reverse a given string.

Please sign-in to view the solution

Implement a function in Python to calculate the square root of any given number up to 2 decimal points precision. Then, optimize the function and implement a caching mechanism to eliminate redundant calculations. Provide an explanation and the solution.

Please sign-in to view the solution

Given a data set of 60 million records and an O(n) computation that takes 2 weeks to complete on a single computer, how would you accelerate the processing time to be completed within 24 hours? Describe your approach and the technologies you would use.

Please sign-in to view the solution

Given two strings `s1`

and `s2`

, write a Python function to check if `s1`

is a rotation of `s2`

. Provide an explanation and the solution.

Please sign-in to view the solution

Design a **rental car service**. Your solution should include considerations for the following aspects:

**Database Schema:**Outline the schema for storing information about cars, rentals, and customers.**Microservices Architecture:**Describe the microservices that would be necessary for this system.**API Endpoints:**List key API endpoints for managing car rentals, including adding a new rental, returning a car, and checking car availability.**Scalability:**Discuss how you would ensure the system scales to handle a large number of rental transactions.

Please sign-in to view the solution

Given two data sets, build a Python application to combine the data and post the combined data into an API. Describe the approach and provide a sample implementation.

Please sign-in to view the solution

**MapReduce Random Lines from Large Log Files:**Using the MapReduce framework, how would you get X amount of random lines from large log files?**Managing a Pool of IPs:**Describe how you would design a system to manage a pool of IP addresses, ensuring efficient allocation and deallocation.**Rotated Array Search:**Given a rotated sorted array, write a Python function to search for a target value. Explain your approach and provide the solution.

Please sign-in to view the solution