
Comviva Technology


Comviva Technology Interview Questions and Answers for Freshers
Q1. Trapping Rainwater Problem Statement
You are given an array ARR
of long type, which represents an elevation map where ARR[i]
denotes the elevation of the ith
bar. Calculate the total amount of rainwater that ca...read more
Calculate the total amount of rainwater that can be trapped within given elevation map.
Iterate through the array to find the maximum height on the left and right of each bar.
Calculate the amount of water that can be trapped above each bar by taking the minimum of the maximum heights on the left and right.
Sum up the trapped water above each bar to get the total trapped water for the elevation map.
Q2. What is inheritance? Show me by a code that shouldn't be a pseudo code but can be in any language
Inheritance is a mechanism in OOP where a new class is derived from an existing class.
Allows for code reusability and saves time
Derived class inherits properties and methods of base class
Can override base class methods in derived class
Can have multiple levels of inheritance
Example: class Dog extends Animal {}
Q3. What is normalization? What do you mean by 1NF, 2NF, 3NF, 4NF?
Normalization is the process of organizing data in a database to reduce redundancy and dependency.
1NF (First Normal Form) - Each column in a table must have atomic values.
2NF (Second Normal Form) - A table must be in 1NF and all non-key attributes must be dependent on the primary key.
3NF (Third Normal Form) - A table must be in 2NF and all non-key attributes must be independent of each other.
4NF (Fourth Normal Form) - A table must be in 3NF and have no multi-valued dependenci...read more
Q4. find first character repeating in the string, ex : 'abcddbc' ans = 'b'
Find the first character that repeats in a given string.
Iterate through the string and keep track of characters seen so far.
If a character is already seen, return it as the first repeating character.
If no repeating character is found, return null.
Q5. Merge Sort Task
Given a sequence of numbers, denoted as ARR
, your task is to return a sorted sequence of ARR
in non-descending order using the Merge Sort algorithm.
Example:
Explanation:
The Merge Sort algorith...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 part has a size of '1'.
Merge the sorted arrays to return one fully sorted array.
Time complexity of Merge Sort is O(n log n).
Q6. Count Nodes within K-Distance Problem Statement
Given a connected, undirected, and acyclic graph where some nodes are marked and a positive integer 'K'. Your task is to return the count of nodes such that the d...read more
Count nodes within K-distance from marked nodes in a connected, undirected, acyclic graph.
Create an adjacency list to represent the graph.
Use BFS to traverse the graph and calculate distances from marked nodes.
Keep track of visited nodes and distances to avoid revisiting nodes.
Return the count of nodes with distances less than 'K' from all marked nodes.
Handle edge cases like empty graph or marked nodes.
Q7. Ways To Make Coin Change
Given an infinite supply of coins of each denomination from a list, determine the total number of distinct ways to make a change for a specified value. If making the change isn't possib...read more
Given coin denominations and a target value, find the total number of ways to make change.
Use dynamic programming to keep track of the number of ways to make change for each value up to the target value.
Iterate through each denomination and update the number of ways to make change for each value.
Handle base cases such as making change for 0 value.
Consider all possible combinations of denominations to make change for the target value.
Q8. Count Occurrences of X in Sorted Array
Given a sorted array or list of integers with size N and an integer X, you need to determine how many times X appears in the array/list.
Input:
The first line of the input...read more
Count occurrences of a given integer in a sorted array.
Use binary search to find the first and last occurrence of X in the array.
Calculate the count by subtracting the indices of the last and first occurrences.
Handle cases where X is not present in the array.
Implement Stack with Linked List
Your task is to implement a Stack data structure using a Singly Linked List.
Explanation:
Create a class named Stack
which supports the following operations, each in O(1) time:
Implement a Stack data structure using a Singly Linked List with operations in O(1) time.
Create a class named Stack with getSize, isEmpty, push, pop, and getTop methods.
Use a Singly Linked List to store the elements of the stack.
Ensure each operation runs in O(1) time complexity.
Handle edge cases like empty stack appropriately.
Example: For input '5 3 10 5 1 2 4', the output should be '10 1 false'.
Top HR Questions asked in Comviva Technology for Freshers

Top Interview Questions from Similar Companies








Reviews
Interviews
Salaries
Users/Month

