
Kellton


Kellton Software Engineer Interview Questions and Answers
Q1. Find All Pairs Adding Up to Target
Given an array of integers ARR
of length N
and an integer Target
, your task is to return all pairs of elements such that they add up to the Target
.
Input:
The first line conta...read more
The task is to find all pairs of elements in an array that add up to a given target.
Iterate through the array and for each element, check if the target minus the element exists in a hash set.
If it exists, add the pair to the result. If not, add the element to the hash set.
Handle cases where the same element is used twice to form a pair.
If no pair is found, return (-1, -1) for that test case.
Q2. Kth Largest Element Problem
Given an array containing N
distinct positive integers and a number K
, determine the Kth largest element in the array.
Example:
Input:
N = 6, K = 3, array = [2, 1, 5, 6, 3, 8]
Output...read more
Find the Kth largest element in an array of distinct positive integers.
Sort the array in non-increasing order and return the Kth element.
Ensure all elements in the array are distinct.
Handle multiple test cases efficiently.
Q3. Maximum Subarray Sum Problem Statement
Given an array arr
of length N
consisting of integers, find the sum of the subarray (including empty subarray) with the maximum sum among all subarrays.
Explanation:
A sub...read more
Find the sum of the subarray with the maximum sum among all subarrays in an array of integers.
Iterate through the array and keep track of the maximum sum subarray seen so far.
At each index, decide whether to include the current element in the subarray or start a new subarray.
Update the maximum sum subarray if a new maximum is found.
Consider edge cases like all negative numbers in the array.
Example: For input arr = [-2, 1, -3, 4, -1], the maximum subarray sum is 4.
Q4. Max Length of Same Indexed Subarrays Problem
Given two integer arrays A
and B
, and an integer C
, the goal is to determine the maximum possible length K
of the same indexed subarrays. The condition is that the s...read more
Find the maximum length of same indexed subarrays based on given conditions.
Iterate through the arrays to find the maximum length of same indexed subarrays.
Calculate the sum of subarrays from A and B, and check if the condition is met.
Return the maximum length that satisfies the condition.
Q5. Distinct Subsequences Problem Statement
You are given a string 'S' of length 'N' which may include duplicate alphabets. Your goal is to calculate the number of distinct subsequences in the string.
Example:
Inpu...read more
Calculate the number of distinct subsequences in a string with possible duplicates.
Iterate through the string and keep track of the count of each character.
Use dynamic programming to calculate the number of distinct subsequences.
Consider the cases where a character is included or excluded in the subsequence.
Modulo the final count by 10^9 + 7 to handle large answers.
Q6. Minimum Number of Swaps to Sort an Array
Find the minimum number of swaps required to sort a given array of distinct elements in ascending order.
Input:
T (number of test cases)
For each test case:
N (size of the...read more
The minimum number of swaps required to sort a given array of distinct elements in ascending order.
Use a graph-based approach to find cycles in the array
Count the number of swaps needed to fix each cycle
Sum up the swaps needed for all cycles to get the total minimum swaps
Q7. Divide Chocolates Problem Statement
Ninja bought chocolate consisting of several chunks, and the sweetness of each chunk is represented in an array ARR
. He wants to divide the chocolate into K + 1
parts (cuts),...read more
The task is to maximize the total sweetness of the part that Ninja will get by dividing chocolates into K + 1 parts.
Iterate through all possible cuts to find the maximum sweetness Ninja can obtain.
Keep track of the minimum sweetness in each part after the cut.
Return the maximum of these minimum sweetness values as the result.
Q8. Partition to K Equal Sum Subsets Problem
Given an array of integers and a positive integer 'K', determine if it is possible to divide the array into 'K' non-empty subsets such that the sum of elements in each s...read more
The problem involves dividing an array into K subsets with equal sum.
Use backtracking to try all possible combinations of dividing the array into K subsets
Keep track of the sum of elements in each subset and check if they are equal to the target sum
Optimize by sorting the array in descending order before starting the backtracking process
Q9. Count Subsequences Problem Statement
Given an integer array ARR
of size N
, your task is to find the total number of subsequences in which all elements are equal.
Explanation:
A subsequence of an array is derive...read more
Count the total number of subsequences in which all elements are equal in an integer array.
Iterate through the array and count the frequency of each element.
Calculate the total number of subsequences for each element using the formula (frequency * (frequency + 1) / 2).
Sum up the total number of subsequences for all elements and return the result modulo 10^9 + 7.
Interview Process at Kellton Software Engineer

Top Software Engineer Interview Questions from Similar Companies








Reviews
Interviews
Salaries
Users/Month

