Chapter 01
1. Programming Logic & Python Fundamentals
Programming is the process of translating algorithmic problem-solving steps into machine-executable instructions. Python is the premier language for placement tests due to its clean syntax, powerful built-in data structures, and expressive standard library.
# Variable declarations and dynamic type checking
student_name = "Karthik"
solved_count = 48
accuracy = 94.75
is_placed = True
# Python 3 f-string formatting
print(f"Student: {student_name} | Solved: {solved_count} | Accuracy: {accuracy:.1f}%")
print(f"Status: {'Ready for Mock Tests' if accuracy >= 90 else 'Needs Practice'}")
Output: Student: Karthik | Solved: 48 | Accuracy: 94.8% • Status: Ready for Mock Tests
Chapter 02
2. Control Flow, Conditionals & Loops
Control structures direct program execution path based on boolean evaluations. Python uses indentation blocks instead of curly braces for scopes.
scores = [85, 92, 78, 95, 88]
# Find indices where score exceeds 90
top_scorers = []
for idx, score in enumerate(scores):
if score >= 90:
top_scorers.append((idx, score))
print("Top candidate indices and scores:", top_scorers)
Output: Top candidate indices and scores: [(1, 92), (3, 95)]
Chapter 03
3. Functions, Variable Scope & Recursion
Functions encapsulate modular, reusable logic. Recursion occurs when a function calls itself to solve smaller subproblems of the same type until reaching a base termination condition.
def gcd(a, b):
# Euclidean algorithm: GCD(a, b) = GCD(b, a % b)
if b == 0:
return a # Base case
return gcd(b, a % b) # Recursive step
print("GCD of 48 and 18:", gcd(48, 18))
Output: GCD of 48 and 18: 6
Chapter 04
4. Core Data Structures: Lists, Tuples, Dictionaries & Sets
Choosing the right data structure directly dictates time and space complexity. Python provides 4 built-in collection types tailored for different access patterns and mutability requirements.
nums = [4, 1, 2, 1, 2, 4, 3, 5, 4]
freq_map = {}
# Build frequency count in O(N) time
for n in nums:
freq_map[n] = freq_map.get(n, 0) + 1
# Extract element with maximum frequency
max_elem = max(freq_map, key=freq_map.get)
print("Frequencies:", freq_map)
print(f"Most frequent element: {max_elem} (appeared {freq_map[max_elem]} times)")
Output: Frequencies: {4: 3, 1: 2, 2: 2, 3: 1, 5: 1} • Most frequent element: 4 (appeared 3 times)
Chapter 05
5. Time & Space Complexity (Big-O Notation)
Big-O notation asymptotically characterizes the execution runtime and memory growth of an algorithm as the input size N approaches infinity. Placement platforms strictly enforce 1–2 second runtime limits.
Chapter 06
6. Classic Placement Coding Patterns Walkthrough
Over 80% of corporate recruitment coding rounds draw directly upon classic data structure paradigms: Two Pointers, Hash Mapping, Sliding Window, and Kadane's Dynamic Programming.
Problem: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
def two_sum(nums, target):
seen = {} # Map: value -> index
for i, num in enumerate(nums):
complement = target - num
if complement in seen:
return [seen[complement], i] # Found match in O(1)
seen[num] = i
return []
# Test:
print(two_sum([2, 7, 11, 15], 9)) # Output: [0, 1]
Complexity: Time O(N), Space O(N)
Problem: Check if a string is a palindrome considering only alphanumeric characters and ignoring cases.
def is_palindrome(s):
# Filter alphanumeric and convert to lowercase
filtered = [char.lower() for char in s if char.isalnum()]
left, right = 0, len(filtered) - 1
while left < right:
if filtered[left] != filtered[right]:
return False
left += 1
right -= 1
return True
# Test:
print(is_palindrome("A man, a plan, a canal: Panama")) # True
Complexity: Time O(N), Space O(N)
Problem: Find the contiguous subarray within an array of numbers that has the largest sum.
def max_subarray_sum(nums):
current_max = global_max = nums[0]
for num in nums[1:]:
# Decide whether to add current number to running sum or start fresh
current_max = max(num, current_max + num)
global_max = max(global_max, current_max)
return global_max
# Test:
print(max_subarray_sum([-2, 1, -3, 4, -1, 2, 1, -5, 4])) # 6 (Subarray [4,-1,2,1])
Complexity: Time O(N), Space O(1)