SquadStack
10+ HDFC Bank Interview Questions and Answers
Q1. Left View of a Binary Tree
Given a binary tree, your task is to print the left view of the tree. The left view of a binary tree contains the nodes visible when the tree is viewed from the left side.
Input:
The ...read more
The task is to print the left view of a binary tree, which contains the nodes visible when viewed from the left side.
Traverse the binary tree level by level and keep track of the leftmost node at each level.
Use a queue for level order traversal and maintain a count of nodes at each level.
Print the leftmost node at each level to get the left view of the binary tree.
Q2. Arithmetic Expression Evaluation Problem Statement
You are provided with a string expression
consisting of characters '+', '-', '*', '/', '(', ')' and digits '0' to '9', representing an arithmetic expression in...read more
Evaluate arithmetic expressions in infix notation with given operators and precedence rules.
Parse the infix expression to postfix using a stack and then evaluate the postfix expression using another stack
Handle operators precedence and associativity while converting to postfix
Use a stack to keep track of operands and operators during evaluation
Ensure to handle parentheses properly to maintain correct order of operations
Q3. Reverse Words in a String: Problem Statement
You are given a string of length N
. Your task is to reverse the string word by word. The input may contain multiple spaces between words and may have leading or trai...read more
Reverse words in a string word by word, removing leading/trailing spaces and extra spaces between words.
Split the input string by spaces to get individual words
Reverse the order of the words
Join the reversed words with a single space in between
Remove any leading or trailing spaces
Q4. Longest Common Subsequence Problem Statement
Given two strings STR1
and STR2
, determine the length of their longest common subsequence.
A subsequence is a sequence that can be derived from another sequence by d...read more
The task is to find the length of the longest common subsequence between two given strings.
Implement a function to find the longest common subsequence between two strings.
Use dynamic programming to solve this problem efficiently.
Iterate through the strings and build a matrix to store the lengths of common subsequences.
Return the length of the longest common subsequence found.
Q5. Maximum Subarray Sum Problem Statement
Given an array of integers, determine the maximum possible sum of any contiguous subarray within the array.
Example:
Input:
array = [34, -50, 42, 14, -5, 86]
Output:
137
E...read more
Find the maximum sum of any contiguous subarray within an array of integers.
Iterate through the array and keep track of the maximum sum of subarrays encountered so far.
At each index, decide whether to include the current element in the subarray or start a new subarray.
Update the maximum sum if a new maximum is found.
Time complexity should be O(N) to iterate through the array once.
Example: For array [34, -50, 42, 14, -5, 86], the maximum subarray sum is 137.
Q6. Find Duplicates in an Array
Given an array ARR
of size 'N', where each integer is in the range from 0 to N - 1, identify all elements that appear more than once.
Return the duplicate elements in any order. If n...read more
Identify duplicate elements in an array of integers within a specified range.
Iterate through the array and keep track of the frequency of each element using a hashmap.
Return elements with frequency greater than 1 as duplicates.
Handle edge cases such as empty array or no duplicates found.
Example: For input [0, 3, 1, 2, 3], output should be [3].
Q7. Covid Vaccination Distribution Problem
As the Government ramps up vaccination drives to combat the second wave of Covid-19, you are tasked with helping plan an effective vaccination schedule. Your goal is to ma...read more
The task is to plan an effective vaccination schedule to maximize the number of vaccines administered on a particular day, while adhering to certain rules.
Given 'n' days for vaccination drive, 'maxVaccines' available, and 'dayNumber' to maximize vaccines on.
Distribute vaccines each day with a positive number, ensuring the difference between consecutive days is not more than 1.
Output the maximum number of vaccines administered on the specified 'dayNumber'.
Example: For n=3, day...read more
Q8. Factorial of a Number Problem Statement
You are provided with an integer 'N'. Your task is to calculate and print the factorial of 'N'. The factorial of a number 'N', denoted as N!, is the product of all positi...read more
Calculate and print the factorial of a given integer 'N'.
Iterate from 1 to N and multiply each number to calculate factorial
Handle edge cases like N=0 or N=1 separately
Use recursion or iterative approach to calculate factorial
Designing a parking lot system involves layout planning, ticketing system, payment methods, security measures, and efficient traffic flow.
Layout planning to maximize space and accommodate different types of vehicles
Implementing a ticketing system for entry and exit tracking
Offering various payment methods such as cash, credit card, and mobile payments
Installing security measures like CCTV cameras and automated gates
Ensuring efficient traffic flow with clear signage and design...read more
ACID properties are a set of properties that guarantee reliability and consistency in database transactions.
Atomicity: Ensures that all operations in a transaction are completed successfully or none at all.
Consistency: Ensures that the database remains in a consistent state before and after the transaction.
Isolation: Ensures that the execution of multiple transactions concurrently does not interfere with each other.
Durability: Ensures that once a transaction is committed, its...read more
Inner Join is a type of SQL join that returns only the rows with matching values in both tables.
Inner Join combines rows from two tables based on a related column between them
It returns only the rows where there is a match between the columns in both tables
Non-matching rows are not included in the result set
Reviews
Interviews
Salaries
Users/Month