
Deutsche Bank


10+ Deutsche Bank Software Developer Intern Interview Questions and Answers
Q1. Longest Consecutive Sequence Problem Statement
You are provided with an unsorted array/list ARR
of N
integers. Your task is to determine the length of the longest consecutive sequence present in the array.
Expl...read more
Find the length of the longest consecutive sequence in an unsorted array of integers.
Iterate through the array and store all elements in a set for constant time lookups.
For each element, check if it is the start of a sequence by looking for its previous number in the set.
Update the length of the current sequence and the maximum length found so far.
Return the maximum length of consecutive sequence found.
Q2. Find the Minimum Cost to Reach Destination via Train
Given 'N' stations on a train route, where the train travels from station 0 to 'N'-1, determine the minimum cost to reach the final station using given ticke...read more
Find the minimum cost to reach the destination via train using given ticket costs for each pair of stations.
Create a 2D array to store the costs from each station to the final destination.
Use dynamic programming to calculate the minimum cost to reach each station.
Iterate through the stations and update the minimum cost based on the previous stations.
Return the minimum cost to reach the final station.
Q3. Next Smaller Palindrome Problem Statement
You are provided with a palindrome number 'N' presented as a string 'S'. The task is to determine the largest palindrome number that is strictly less than 'N'.
Input:
T...read more
Given a palindrome number 'N' as a string, find the largest palindrome number strictly less than 'N'.
Iterate from the middle towards the start and end of the number to find the next smaller palindrome.
Handle cases where the middle digit is 0 by borrowing from adjacent digits.
Ensure the resulting number does not have leading zeros, except when the answer is 0.
Q4. Matrix Bit Flipping Problem
In this task, you're provided with a binary square matrix of size 'N * N' named MAT
. The task requires you to perform row and column flips whenever a zero (0) is encountered in the m...read more
Count the total number of flips required in a binary matrix when encountering zeros.
Iterate through the matrix and whenever a zero is encountered, flip all 1s in the corresponding row and column.
Keep track of the total number of flips required.
Return the total count of flips at the end.
Q5. Jump Game Problem Statement
In this problem, you are given an array ARR
consisting of N
integers. Your task is to determine the minimum number of jumps required to reach the last index of the array N - 1
. At an...read more
The problem involves finding the minimum number of jumps required to reach the last index of an array, where each element represents the maximum distance that can be jumped from that index.
Start from index 0 and keep track of the maximum reachable index at each step.
Update the maximum reachable index as you iterate through the array.
Increment the jump count when you reach the end of the current reachable range.
Continue until the last index is reached.
Q6. Query and Matrix Problem Statement
You are given a binary matrix with 'M' rows and 'N' columns, initially consisting of all 0s. You will receive 'Q' queries, which can be of four types:
Query 1: 1 R index
Query ...read more
Implement a function to process queries on a binary matrix by flipping rows/columns and counting zeros.
Create a binary matrix with all zeros initially.
Process queries by flipping rows/columns and counting zeros as per query type.
Return the count of zeros for type 2 queries.
Handle constraints efficiently to optimize the solution.
Example: For input M=3, N=3 and queries 1R1, 1R2, 2C1, the output should be 1.
Q7. Sort a Stack Problem Statement
You are provided with a stack consisting of 'N' integers. The goal is to sort this stack in descending order by utilizing recursion.
Allowed Stack Operations:
is_empty(S) : Check ...read more
Sort a stack in descending order using recursion without using loop constructs.
Implement a recursive function to sort the stack in descending order.
Use the provided stack operations to manipulate the stack.
Recursively pop elements from the original stack and insert them in the correct order in a temporary stack.
Once all elements are sorted in the temporary stack, move them back to the original stack.
Repeat the process until the original stack is sorted in descending order.
Q8. Rooks Placing Problem Statement
You are given an n×n chessboard where rows and columns are numbered from 0 to n-1. Each cell (r, c) is located at the intersection of row 'r' and column 'c'. A rook is a chess pi...read more
Given a chessboard with rooks placed, determine the maximum number of additional rooks that can be added without attacking each other.
Iterate through each row and column to find empty cells where additional rooks can be placed.
Keep track of the number of additional rooks that can be added and their positions.
Output the maximum number of additional rooks and their positions in lexicographical order.
Q9. Merge Sort Problem Statement
You are given a sequence of numbers, ARR
. Your task is to return a sorted sequence of ARR
in non-descending order using the Merge Sort algorithm.
Explanation:
The Merge Sort algorit...read more
Implement Merge Sort algorithm to sort a sequence of numbers in non-descending order.
Divide the input array into two halves recursively until each array has only one element.
Merge the sorted halves to produce a completely sorted array.
Time complexity of Merge Sort is O(n log n).
Example: Input: [3, 1, 4, 1, 5], Output: [1, 1, 3, 4, 5]
Q10. Dijkstra's Shortest Path Problem
Given an undirected graph with ‘V’ vertices (labeled 0, 1, ... , V-1) and ‘E’ edges, where each edge has a weight representing the distance between two connected nodes (X, Y).
Y...read more
Dijkstra's algorithm is used to find the shortest path from a source node to all other nodes in a graph with weighted edges.
Implement Dijkstra's algorithm to find the shortest path distances from the source node to all other nodes.
Use a priority queue to efficiently select the next node with the shortest distance.
Update the distances of neighboring nodes based on the current node's distance and edge weights.
Handle disconnected vertices by assigning a large value (e.g., 214748...read more
Q11. Rat in a Maze Problem Statement
You need to determine all possible paths for a rat starting at position (0, 0) in a square maze to reach its destination at (N-1, N-1). The maze is represented as an N*N matrix w...read more
Find all possible paths for a rat in a maze from source to destination.
Use backtracking to explore all possible paths in the maze.
Keep track of visited cells to avoid revisiting them.
Recursively try moving in all directions (up, down, left, right) until reaching the destination.
Add the path to the result list when the destination is reached.
Sort the result list in alphabetical order before returning.
Q12. Cycle Detection in a Singly Linked List
Determine if a given Singly Linked List of integers contains a cycle.
Explanation:
A cycle in a linked list occurs when a node's next pointer points back to a previous no...read more
Detect if a singly linked list contains a cycle using Floyd's Tortoise and Hare algorithm.
Use Floyd's Tortoise and Hare algorithm to detect cycle in a linked list
Initialize two pointers, slow and fast, and move them at different speeds
If there is a cycle, the two pointers will eventually meet
Time complexity: O(N), Space complexity: O(1)
Q13. Consecutive Sum Representation of a Number
Find the number of ways the given number 'N' can be expressed as the sum of two or more consecutive natural numbers.
Example:
Input:
N = 9
Output:
2
Explanation:
The n...read more
Find the number of ways a given number can be expressed as the sum of two or more consecutive natural numbers.
Use a sliding window approach to iterate through consecutive numbers and check if their sum equals the given number.
Keep track of the count of valid consecutive sums found.
Return the count of valid consecutive sums as the final answer.
Q14. Remove the Kth Node from the End of a Linked List
You are given a singly Linked List with 'N' nodes containing integer data and an integer 'K'. Your task is to delete the Kth node from the end of this Linked Li...read more
Implement a function to remove the Kth node from the end of a singly linked list.
Traverse the list to find the length 'N' of the linked list.
Calculate the position of the node to be removed from the beginning as 'N - K + 1'.
Traverse the list again and remove the node at the calculated position.
SQL query to select people below age 75
Use SELECT statement to retrieve data
Use WHERE clause to filter out people above age 75
Example: SELECT * FROM people WHERE age < 75
The diamond problem occurs in multiple inheritance when a class inherits from two classes that have a common ancestor.
Occurs in multiple inheritance when a class inherits from two classes that have a common ancestor
Results in ambiguity in the inheritance hierarchy
Can lead to conflicts in method resolution
Heaps are implemented using arrays with a binary tree structure.
Heaps are complete binary trees where each node has a value greater than or equal to its children in a max heap, or less than or equal to its children in a min heap.
The root of the heap is stored at index 0 in the array, and for any node at index i, its left child is at index 2i+1 and its right child is at index 2i+2.
Heap operations like insertion and deletion are performed by maintaining the heap property throug...read more
More about working at Deutsche Bank





Top Software Developer Intern Interview Questions from Similar Companies








Reviews
Interviews
Salaries
Users/Month

