If youβre a fresher and youβre in 3rd/4th year but still donβt know coding, donβt start with LeetCode Hard.
Get these questions down first. A lot of service-based companies test these basic coding problems in fresher interviews:
1. Reverse a string without using a built-in reverse function
2. Check whether a string or number is a palindrome
3. Find the largest and smallest element in an array
4. Find duplicate elements in an array
5. Find the second-largest element without sorting
6. Check whether a number is prime
7. Print the first N Fibonacci numbers
8. Find factorial using recursion
9. Check whether two strings are anagrams
10. Count the frequency of each character in a string
11. Find the missing number from 1 to N
12. Find two numbers whose sum equals a target
You donβt need to know everything.
Try to solve these confidently first.
Get these questions down first. A lot of service-based companies test these basic coding problems in fresher interviews:
1. Reverse a string without using a built-in reverse function
2. Check whether a string or number is a palindrome
3. Find the largest and smallest element in an array
4. Find duplicate elements in an array
5. Find the second-largest element without sorting
6. Check whether a number is prime
7. Print the first N Fibonacci numbers
8. Find factorial using recursion
9. Check whether two strings are anagrams
10. Count the frequency of each character in a string
11. Find the missing number from 1 to N
12. Find two numbers whose sum equals a target
You donβt need to know everything.
Try to solve these confidently first.
π₯ SQL Interview Case Studies (Advanced Business Scenarios)
π§ Case Study 1: Find Repeat Customers
π Orders Table
order_id customer_id
1 101
2 102
3 101
β Business Question
Find customers who placed more than 1 order.
β Solution
SELECT customer_id,
COUNT(*) AS total_orders
FROM orders
GROUP BY customer_id
HAVING COUNT(*) > 1;
π§ Case Study 2: Highest Paid Employee Per Department
β Business Question
Find highest paid employee in every department.
β Solution
WITH RankedEmployees AS (
SELECT *,
ROW_NUMBER() OVER(
PARTITION BY department
ORDER BY salary DESC
) rn
FROM employees
)
SELECT *
FROM RankedEmployees
WHERE rn = 1;
π§ Case Study 3: Find Inactive Customers
β Business Question
Customers who haven't ordered in the last 6 months.
β Solution
SELECT c.customer_id,
c.name
FROM customers c
LEFT JOIN orders o
ON c.customer_id = o.customer_id
GROUP BY c.customer_id, c.name
HAVING MAX(o.order_date) <
DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
π§ Case Study 4: Product Generating Highest Revenue
π Sales Table
product_id amount
β Solution
SELECT product_id,
SUM(amount) AS revenue
FROM sales
GROUP BY product_id
ORDER BY revenue DESC
LIMIT 1;
π§ Case Study 5: Employee Salary Above Department Average
β Solution
WITH DeptAvg AS (
SELECT department,
AVG(salary) avg_salary
FROM employees
GROUP BY department
)
SELECT e.*
FROM employees e
JOIN DeptAvg d
ON e.department = d.department
WHERE e.salary > d.avg_salary;
π§ Case Study 6: Running Total Sales
β Business Question
Calculate cumulative sales.
β Solution
SELECT order_date,
amount,
SUM(amount) OVER(
ORDER BY order_date
) AS running_total
FROM sales;
π§ Case Study 7: Top 3 Products Per Category
β Solution
WITH RankedProducts AS (
SELECT *,
ROW_NUMBER() OVER(
PARTITION BY category
ORDER BY sales DESC
) rn
FROM products
)
SELECT *
FROM RankedProducts
WHERE rn <= 3;
π― Practice Tasks
1οΈβ£ Find customer with highest number of orders
2οΈβ£ Find lowest salary employee per department
3οΈβ£ Find products never sold
4οΈβ£ Find departments with average salary > company average
5οΈβ£ Find month with lowest sales
β‘οΈ Mini Challenge π₯
Banking Scenario
Tables:
Accounts
account_id customer_name
Transactions
transaction_id account_id amount transaction_date
Question
π Find the top 3 customers with highest total transaction amount in the last 1 year.
π₯ Interview Tip
When solving case studies:
1οΈβ£ Understand business question
2οΈβ£ Identify tables
3οΈβ£ Identify JOINs
4οΈβ£ Identify Aggregations
5οΈβ£ Decide whether Window Function is needed
π§ Case Study 1: Find Repeat Customers
π Orders Table
order_id customer_id
1 101
2 102
3 101
β Business Question
Find customers who placed more than 1 order.
β Solution
SELECT customer_id,
COUNT(*) AS total_orders
FROM orders
GROUP BY customer_id
HAVING COUNT(*) > 1;
π§ Case Study 2: Highest Paid Employee Per Department
β Business Question
Find highest paid employee in every department.
β Solution
WITH RankedEmployees AS (
SELECT *,
ROW_NUMBER() OVER(
PARTITION BY department
ORDER BY salary DESC
) rn
FROM employees
)
SELECT *
FROM RankedEmployees
WHERE rn = 1;
π§ Case Study 3: Find Inactive Customers
β Business Question
Customers who haven't ordered in the last 6 months.
β Solution
SELECT c.customer_id,
c.name
FROM customers c
LEFT JOIN orders o
ON c.customer_id = o.customer_id
GROUP BY c.customer_id, c.name
HAVING MAX(o.order_date) <
DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
π§ Case Study 4: Product Generating Highest Revenue
π Sales Table
product_id amount
β Solution
SELECT product_id,
SUM(amount) AS revenue
FROM sales
GROUP BY product_id
ORDER BY revenue DESC
LIMIT 1;
π§ Case Study 5: Employee Salary Above Department Average
β Solution
WITH DeptAvg AS (
SELECT department,
AVG(salary) avg_salary
FROM employees
GROUP BY department
)
SELECT e.*
FROM employees e
JOIN DeptAvg d
ON e.department = d.department
WHERE e.salary > d.avg_salary;
π§ Case Study 6: Running Total Sales
β Business Question
Calculate cumulative sales.
β Solution
SELECT order_date,
amount,
SUM(amount) OVER(
ORDER BY order_date
) AS running_total
FROM sales;
π§ Case Study 7: Top 3 Products Per Category
β Solution
WITH RankedProducts AS (
SELECT *,
ROW_NUMBER() OVER(
PARTITION BY category
ORDER BY sales DESC
) rn
FROM products
)
SELECT *
FROM RankedProducts
WHERE rn <= 3;
π― Practice Tasks
1οΈβ£ Find customer with highest number of orders
2οΈβ£ Find lowest salary employee per department
3οΈβ£ Find products never sold
4οΈβ£ Find departments with average salary > company average
5οΈβ£ Find month with lowest sales
β‘οΈ Mini Challenge π₯
Banking Scenario
Tables:
Accounts
account_id customer_name
Transactions
transaction_id account_id amount transaction_date
Question
π Find the top 3 customers with highest total transaction amount in the last 1 year.
π₯ Interview Tip
When solving case studies:
1οΈβ£ Understand business question
2οΈβ£ Identify tables
3οΈβ£ Identify JOINs
4οΈβ£ Identify Aggregations
5οΈβ£ Decide whether Window Function is needed
JavaScript Interview Questions
These are some of the most important JavaScript interview questions every developer should know, from closures and hoisting to promises, async/await, CORS, debouncing, throttling, and more.
These are some of the most important JavaScript interview questions every developer should know, from closures and hoisting to promises, async/await, CORS, debouncing, throttling, and more.