You are tasked with designing a secure database system for Yahoo's Paranoids team, focusing on a Linux environment hosted on AWS. The system should ensure data integrity and protection against cyber threats. Additionally, propose a machine learning approach to detect and mitigate potential security breaches. Describe your approach, the technologies you would use, and the steps involved in the implementation.
Please sign-in to view the solution
Design a secure database system for a cybersecurity team, focusing on a Linux environment hosted on AWS. The system must ensure data integrity and protection against cyber threats. Additionally, propose a machine learning solution to detect and mitigate potential security breaches. Detail your approach, the technologies you would use, and the steps involved in the implementation.
Please sign-in to view the solution
Discuss ACID properties and their significance in database transactions.
Please sign-in to view the solution
Given the following database schema for an e-commerce platform:
Customers Table:
customer_id
(Primary Key)first_name
last_name
email
Orders Table:
order_id
(Primary Key)customer_id
(Foreign Key)order_date
total_amount
OrderDetails Table:
order_detail_id
(Primary Key)order_id
(Foreign Key)product_id
(Foreign Key)quantity
price
Products Table:
product_id
(Primary Key)product_name
category
Write a complex SQL query to retrieve the top 5 customers who have spent the most on products in the 'Electronics' category over the past year. The query should also return the total amount spent by these customers and the number of orders they placed in the past year.
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 the following database schema for a retail platform:
Customers Table:
customer_id
(Primary Key)first_name
last_name
email
Orders Table:
order_id
(Primary Key)customer_id
(Foreign Key)order_date
total_amount
OrderDetails Table:
order_detail_id
(Primary Key)order_id
(Foreign Key)product_id
(Foreign Key)quantity
price
Products Table:
product_id
(Primary Key)product_name
category
Write a complex SQL query that performs the following tasks:
- Use a
JOIN
to retrieve the customer's name and email along with the total amount they spent on each order. - Use a
UNION
to combine the result with a similar query that retrieves the total number of products ordered by each customer. - Use a
WINDOW FUNCTION
to rank customers based on their total spending. - Use a
SUBQUERY
to find customers who have placed more than 5 orders.
The final result should include the customer's name, email, total amount spent, total products ordered, and their spending rank.
Please sign-in to view the solution
Explain how you would use advanced SQL techniques to identify consecutive numbers and segregate absent and present dates.
Please sign-in to view the solution
How would you put a cap on the number of items a seller is allowed to have on the Amazon marketplace? What would be the criteria for selecting which items stay on the marketplace if this limit was imposed and sellers were over the limit?
Please sign-in to view the solution
How would you diagnose and resolve issues when a business intelligence report breaks in a production environment?
Please sign-in to view the solution
What is OLAP and what are its differences compared to other database types?
Please sign-in to view the solution
If you have two SQL database tables that are not joined together, how would you create another table to join them.
Please sign-in to view the solution
You are given a database containing customer orders. The database currently has redundant and repetitive data, leading to inconsistency and excess storage usage. Explain how you would apply normalization techniques to this database. What specific steps would you take to achieve Third Normal Form (3NF)? Provide example tables before and after normalization.
Please sign-in to view the solution
Imagine you are tasked with creating a test plan for a new inventory management system for a company. Describe the steps and key elements you would include in your test plan to ensure comprehensive and effective coverage of the system.
Please sign-in to view the solution
Explain and provide examples of software testing and development coding questions that involve basic data structures. Consider questions that cover arrays, linked lists, stacks, and queues. Provide a detailed solution for each example.
Please sign-in to view the solution
You are analyzing sales data and notice that there are anomalies in the data for several key regions over the past quarter. Specifically, the sales figures for certain products are either too high or too low compared to historical data. Describe a step-by-step approach to identify and address these anomalies using SQL and Python.
Please sign-in to view the solution
Test scenario was Banking Application:
- Registration page
- Login page
- Transaction
- Ticket raise
types of testing: -> functional and non functional and its differences -> monkey testing -> guerrilla testing -> unit testing -> integration testing -> system testing -> acceptance testing and a lot more.
Please sign-in to view the solution
Given a string, write a function in Python to remove all duplicate characters while preserving the original order of characters.
Please sign-in to view the solution
Write a function in Python to traverse an array both from back to front and vice versa. Print the elements in both orders.
Please sign-in to view the solution
As a software engineer, you are tasked with optimizing a given piece of code to improve its efficiency in terms of Big O notation. Describe at least five general strategies you would employ to enhance the code's performance.
Please sign-in to view the solution
Provide counter examples to the time complexity analysis of a Binary Search Tree (BST).
Please sign-in to view the solution
What is the difference between Compatibility Testing and Integrity Testing in the context of software and data systems? Provide a detailed comparison highlighting the purpose, scope, and techniques used in each type of testing.
Please sign-in to view the solution
Imagine you are a Data Analyst at Amazon working on improving the product recommendation algorithm. You are given a dataset with user_id, product_id, rating, and timestamp. Your task is to identify the top 5 most popular products (most purchased) in the last 30 days. What steps would you take to solve this problem using Python and SQL?
Please sign-in to view the solution
Given an array of integers where every element appears twice except for one, write a function to find that single element. Explain the approach and also provide a code solution in Python.
Please sign-in to view the solution
Given two unsorted arrays of integers, write a function to determine if the arrays contain the same elements, regardless of their order. Explain your approach and provide a Python code solution.
Please sign-in to view the solution
Explain the use of the HAVING clause and Aggregate Functions in SQL. Provide examples of SQL queries that demonstrate their usage with a detailed explanation for each.
Please sign-in to view the solution
What is Integrity Testing in the context of data systems? Describe its importance and a common approach to perform integrity testing when migrating data from one system to another.
Please sign-in to view the solution
What's the difference between test data and train data in your project?
Please sign-in to view the solution
Find the number of occurrences of each character in a given string.
Please sign-in to view the solution
Given a binary tree, write a function to invert the binary tree (i.e., swap the left and right children of every node).
Implement this transformation in Python.
Example:
Input:
4
/ \
2 7
/ \ / \
1 3 6 9
Output:
4
/ \
7 2
/ \ / \
9 6 3 1
Please sign-in to view the solution
Explain the time complexity of operations in a Binary Search Tree (BST). Provide both average-case and worst-case complexities.
Please sign-in to view the solution
Write a program to group anagrams from a given list of strings. This is a common problem on LeetCode.
Please sign-in to view the solution
Write a function in Python to find the sum of all digits in a given number.
Please sign-in to view the solution
- Given a number, find the nearest palindrome.
- Given an array of length
n
containing numbers between 1 to 99, print the last two digits of the result after multiplying alln
numbers in the array.
Please sign-in to view the solution
- Write test cases for a video calling app on a mobile device.
- Write a program to find consecutive duplicate letters in each word of the sentence and print the sentence without duplicate letters.
- Find a series of numbers in an array which gives the sum value as 3.
Please sign-in to view the solution
Write a function in Python and Java to find the union of two strings. The union of two strings includes all unique characters present in either of the strings.
Please sign-in to view the solution
You're provided with a database containing customer interaction data collected from a web application. Using SQL, extract the list of customers who have logged in more than 5 times in the past 30 days but have not made any purchases. Explain the steps and SQL query you would use to achieve this. Assume the database has the following tables:
logins
(fields:customer_id
,login_date
)purchases
(fields:customer_id
,purchase_date
,amount
)
Please sign-in to view the solution
In the context of a business analysis for a web application, you are given two data tables: logins
and purchases
. You are asked to find out the engagement level of customers who have interacted with the application. Write a SQL query to determine the list of customers who have logged in more than 5 times in the last 30 days and have made at least one purchase. Provide the steps and the final SQL query. The table structures are:
logins
(fields:customer_id
,login_date
)purchases
(fields:customer_id
,purchase_date
,amount
)
Please sign-in to view the solution
You need to write a SQL query to reverse the digits of a given integer. Assume the integer is stored in a table called numbers
with a single column value
. Provide an example integer and show how your query processes it to produce the reversed number.
Please sign-in to view the solution
In a multi-threaded environment, you have a log table thread_logs
with the columns thread_id
, start_time
, end_time
, and operation
. You need to analyze the performance of each thread by calculating the total time spent on operations by each thread. Write an SQL query to summarize the total processing time for each thread. Provide the steps and the final SQL query.
Please sign-in to view the solution
You are given a table employees
with columns employee_id
, name
, and department_id
. You also have a table departments
with columns department_id
and department_name
. Describe how you would leverage a HashMap (or equivalent data structure) approach to optimize querying the department name for each employee in an SQL environment. Provide the steps and the final SQL query.
Please sign-in to view the solution
You need to write an SQL query that identifies whether a given integer in a table is a prime number. Assume the table numbers
has a single column value
containing positive integers. Write a query to determine if each number is prime and return the value
along with a is_prime
flag. Provide the steps and the final SQL query.
Please sign-in to view the solution
You are given a list of customer IDs in a Python list, which might contain duplicates. Write a Python function that uses a HashSet to determine if there are any duplicates in the list.
Please sign-in to view the solution
Write a function in Python to find a pair of numbers in an array such that their product is the maximum possible.
Please sign-in to view the solution
Write a function to reverse a linked list in groups of K (any number) in Python and Java.
Please sign-in to view the solution
You are given a table orders
with columns order_id
, customer_id
, and order_date
. Additionally, you have a table customers
with columns customer_id
, customer_name
, and customer_email
. Explain how you can use principles similar to a Hash Table to efficiently retrieve customer details for each order in an SQL database. Provide the steps and the final SQL query.
Please sign-in to view the solution
Suppose you are working with a SQL database, and you have a table sales_data
with columns product_id
, region
, and sales_amount
. You have noticed that there are some missing values in the sales_amount
column for certain region
s.
Write a SQL query to identify all regions where any sales_amount
value is missing.
Please sign-in to view the solution
You are given a singly linked list and you need to write a function in Python to reverse the linked list. Assume the linked list node is defined as follows:
class ListNode:
def __init__(self, value=0, next=None):
self.value = value
self.next = next
Write a function reverse_linked_list
that takes the head of the linked list as an argument and returns the new head of the reversed list.
Please sign-in to view the solution
Explain the key steps and considerations in designing a database. Include how you would handle requirements gathering, schema design, normalization, indexing, and ensuring data integrity.
Please sign-in to view the solution
Write a function to find the shortest path between two points on a 2D matrix. The matrix contains cells that can either be empty (0) or blocked (1). You can move up, down, left, or right but cannot move through blocked cells.
Please sign-in to view the solution
What is a Binary Search Tree? What is a Doubly Circular Linked List?
Please sign-in to view the solution
Write a function in Python and Java to check if parentheses are closed correctly in a given string. The function should support different types of parentheses: ()
, {}
, and []
.
Please sign-in to view the solution
Write an SQL query to find the third highest salary from an Employee table. Additionally, write a query to find the count of employees in each department from the Employee and Department tables.
Assume the Employee table (Emp
) has columns: EmpID
, EmpName
, DeptID
, Salary
, and the Department table (Dept
) has columns: DeptID
, DeptName
.
Please sign-in to view the solution
You are given a table articles
containing a column content
which holds textual data. Write an SQL query to count the frequency of each word in the content
column across all rows. Explain the steps and the final SQL query to achieve this. Assume your SQL environment supports common table expressions (CTEs) and string functions.
Please sign-in to view the solution
Describe the method to check if there is a loop in a linked list. Provide the algorithm and example code in Python.
Please sign-in to view the solution
As a QA Engineer, you encounter a bug that appears to affect some users, but you are unable to reproduce it. Describe the steps you would take to investigate and resolve this issue.
Please sign-in to view the solution
- Write a function to find the closest palindrome number to a given number.
- Write a function to determine if an array contains duplicate numbers.
- Write a function to print numbers in a rhombus shape:
1 121 12321 121 1
Please sign-in to view the solution