THURSDAY CHALLENGE — WEEK 1
Date: 09:10:2025
1. Programming Fundamentals (C / C++ / Java / Python)
Question: Predict the Output / Logic
#include <iostream>
using namespace std;
int main() {
int x = 10;
for(int i = 0; i < 3; i++) {
x += i * 2;
cout << x;
return 0;
Task: What will be printed?
Concepts: Loops, increment logic, dry run skills.
Bonus: Explain what happens if x is declared inside the loop.
2.Data Structures & Algorithms
Question:
Write a function to return the second largest number in an array without sorting it.
Input Example:
arr = [4, 9, 1, 9, 7]
Expected Output:
Bonus: What’s your time complexity?
3.Algorithmic Thinking
Question:
Find the count of pairs in an array whose sum equals a given number k. Also try to write
program for the question in your preferred language.
Input:
arr = [1, 5, 7, -1, 5]
k=6
Expected Output:
Concepts: Hashmap usage, nested loop optimization.
4.SQL & DBMS
Question:
You have a table
Employee(emp_id, name, salary, dept_id)
Write a query to find the second highest salary in each department.
Hint: Use window functions or subqueries.
Bonus: What happens if two people have the same top salary?
5.Debug / Error Finding (C or Python)
Question (Python):
def add_numbers(a, b):
print("Sum is: " + a + b)
add_numbers(5, 10)
Task: Find the error and fix it.
Concepts: Type casting, string concatenation.
Problem:
Given an integer, find the sum of its digits until the result becomes a single digit.
Example:
Input: 9875
Output: 2 (because 9+8+7+5 = 29 → 2+9 = 11 → 1+1 = 2)
Hint: Try recursion or modulo trick (digital root).
Loops – Repeating a block of code until a condition is met.
Increment Logic – Increasing a variable’s value (like i++) to move through iterations or
data.
Dry Run Skills – Manually simulating code execution step-by-step to predict output.
Time Complexity – A measure of how fast an algorithm runs as input size grows (Big O
notation).
Nested Loop Optimization – Reducing inner loop work using precomputation,
HashMaps, or early exits.
HashMap – Stores unique keys mapped to values, allowing quick search, insert, and
delete.
Subqueries – Queries nested inside another query to filter or calculate results
dynamically.
Window Functions (SQL) – Functions like ROW_NUMBER() or SUM() OVER() that
perform calculations across a result set without grouping.
Type Casting – Converting one data type to another (e.g., int → float).
String Concatenation – Joining strings together using + or template literals.
Recursion – A function calling itself to solve smaller parts of a problem.
Modulo Trick (Digital Root) – Using % to simplify problems like finding repeated sum
of digits until one digit remains (n % 9 pattern).