SAP
20+ ABIL Group Interview Questions and Answers
Q1. Subarray Sums I Problem Statement
You are provided with an array of positive integers ARR
that represents the strengths of different “jutsus” (ninja techniques). You are also given the strength of the enemy S
, ...read more
Count the number of subarrays whose combined strength matches the given enemy strength.
Iterate through all subarrays and calculate their sum to check if it matches the enemy strength.
Use two pointers technique to efficiently find subarrays with sum equal to the enemy strength.
Consider edge cases like when the enemy strength is 0 or when all elements in the array are equal to the enemy strength.
Q2. Move Zeroes to End Problem Statement
Given an unsorted array of integers, modify the array such that all the zeroes are moved to the end, while maintaining the order of non-zero elements as they appear original...read more
Move all zeroes to the end of an unsorted array while maintaining the order of non-zero elements.
Iterate through the array and maintain two pointers - one for non-zero elements and one for zeroes.
Swap non-zero elements with zeroes to move zeroes to the end of the array.
Maintain the relative order of non-zero elements while moving zeroes to the end.
Q3. Swap Numbers Without Temporary Variable
Your task is to interchange the values of two numbers given as variables 'X' and 'Y' without using a temporary variable or any additional variable.
Explanation:
You need ...read more
Swap two numbers without using a temporary variable.
Use bitwise XOR operation to swap the values of X and Y without using a temporary variable.
The XOR operation works by toggling the bits of the numbers.
Example: X = 10, Y = 20. X = X XOR Y, Y = X XOR Y, X = X XOR Y. After swapping, X = 20, Y = 10.
Q4. 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]
Q5. DFS Traversal Problem Statement
Given an undirected and disconnected graph G(V, E)
, where V
is the number of vertices and E
is the number of edges, the connections between vertices are provided in the 'GRAPH' m...read more
DFS traversal to find connected components in an undirected and disconnected graph.
Use Depth First Search (DFS) algorithm to traverse the graph and find connected components.
Maintain a visited array to keep track of visited vertices.
For each unvisited vertex, perform DFS to explore all connected vertices and form a connected component.
Repeat the process until all vertices are visited and print the connected components.
Q6. Minimum Number of Platforms Problem
Your task is to determine the minimum number of platforms required at a railway station so that no train has to wait.
Explanation:
Given two arrays:
AT
- representing the ar...read more
Determine the minimum number of platforms needed at a railway station so that no train has to wait.
Sort the arrival and departure times arrays in ascending order.
Use two pointers to iterate through the arrays and keep track of the number of platforms needed.
Increment the number of platforms needed when a train arrives and decrement when a train departs.
Return the maximum number of platforms needed at any point.
Q7. Shape and Method Overriding Problem Statement
Create a base class called Shape
that contains a field named shapeType
and a method printMyType
.
Implement two derived classes:
- Square: This class inherits from
Sh...read more
Create base class Shape with field shapeType and method printMyType. Implement Square and Rectangle classes with calculateArea method.
Create a base class Shape with shapeType field and printMyType method.
Implement Square and Rectangle classes inheriting from Shape.
Include additional fields and methods in Square and Rectangle classes.
Override printMyType method in Square and Rectangle classes to output their respective types.
Ensure proper encapsulation and validation of length...read more
Q8. Uncommon Characters Problem Statement
Given two strings S1
and S2
comprised of lowercase alphabets, determine the list of characters that are uncommon between these strings. A character is considered uncommon i...read more
Given two strings, find uncommon characters in lexicographical order.
Iterate through each character in both strings and keep track of their frequency using a hashmap.
Iterate through the hashmap and add characters with frequency 1 to the result list.
Sort the result list in lexicographical order and return it as the final output.
Q9. Remove Duplicates Problem Statement
You are given an array of integers. The task is to remove all duplicate elements and return the array while maintaining the order in which the elements were provided.
Example...read more
Remove duplicates from an array while maintaining order.
Use a set to keep track of unique elements.
Iterate through the array and add elements to the set if not already present.
Convert the set back to an array to maintain order.
A deadlock is a situation in which two or more processes are unable to proceed because each is waiting for the other to release a resource.
Deadlock occurs when processes have acquired resources and are waiting for additional resources that are held by other processes.
Four necessary conditions for deadlock are mutual exclusion, hold and wait, no preemption, and circular wait.
Solutions to deadlock include prevention, avoidance, detection, and recovery.
Prevention involves ensuri...read more
A friend function in OOP is a function that is not a member of a class but has access to its private and protected members.
Friend functions are declared inside a class with the 'friend' keyword.
They can access private and protected members of the class.
They are not member functions of the class, but have the same access rights as member functions.
Friend functions are often used for operator overloading or to allow external functions to access private members of a class.
C is a procedural programming language while C++ is an object-oriented programming language with features like classes and inheritance.
C is a procedural programming language, while C++ is a multi-paradigm language with support for object-oriented programming.
C does not support classes and objects, while C++ does.
C does not have features like inheritance and polymorphism, which are present in C++.
C is a subset of C++, meaning that all valid C programs are also valid C++ progra...read more
Multithreading allows for concurrent execution of tasks, improving performance and responsiveness.
Improved performance by utilizing multiple CPU cores efficiently
Enhanced responsiveness as tasks can run concurrently without blocking each other
Better resource utilization by allowing tasks to be executed in parallel
Facilitates easier handling of complex tasks by breaking them into smaller threads
Examples: Web servers handling multiple requests simultaneously, video games render...read more
Q14. what is the minimum number of coins to reach the target with the coins 1,2,5
The minimum number of coins to reach a target amount can be calculated using dynamic programming.
Use dynamic programming to calculate the minimum number of coins needed to reach the target amount.
Start by initializing an array to store the minimum number of coins needed for each amount from 0 to the target amount.
Iterate through the coin denominations and update the minimum number of coins needed for each amount based on the current coin denomination.
Elements can be inserted at the back of the queue and deleted from the front.
To insert an element, use the 'enqueue' operation to add it to the back of the queue.
To delete an element, use the 'dequeue' operation to remove it from the front of the queue.
Insertion and deletion operations in a queue have a time complexity of O(1).
Process synchronization is the coordination of multiple processes to ensure they do not interfere with each other while accessing shared resources.
Preventing race conditions by using synchronization mechanisms like locks, semaphores, and monitors
Ensuring mutual exclusion to prevent multiple processes from accessing shared resources simultaneously
Implementing synchronization to maintain the order of execution and avoid deadlocks
Examples include producer-consumer problem, reade...read more
Q17. Find number of nodes in a tree and it's time complexity
To find number of nodes in a tree, perform a depth-first or breadth-first traversal and count the nodes. Time complexity is O(n).
Perform a depth-first or breadth-first traversal of the tree
Count the nodes as you traverse the tree
Time complexity is O(n) where n is the number of nodes in the tree
Q18. what is abstraction and how do you implement it ??
Abstraction is the concept of hiding complex implementation details and showing only the necessary information.
Abstraction allows developers to focus on the essential features of an object or system.
It helps in reducing complexity and improving efficiency in software development.
Implement abstraction in programming by using abstract classes and interfaces.
Example: In a car, we don't need to know the internal workings of the engine to drive it.
Example: In programming, a shape ...read more
Function overriding is when a subclass provides a specific implementation of a method that is already provided by its parent class.
Occurs in inheritance when a subclass has a method with the same name and parameters as a method in its superclass
The method in the subclass overrides the method in the superclass
Used to achieve runtime polymorphism in object-oriented programming
Example: class Animal { void sound() { System.out.println('Animal sound'); } } class Dog extends Animal...read more
Q20. Byte stream to human readable format without using library
Convert byte stream to human readable format without using library
Iterate through the byte stream and convert each byte to its ASCII character representation
Concatenate the ASCII characters to form the human readable format
Handle special characters and edge cases appropriately
More about working at SAP
Interview Process at ABIL Group
Top Software Developer Intern Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month