Add office photos
Employer?
Claim Account for FREE

American Express

4.2
based on 3.1k Reviews
Video summary
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by

10+ HCL Group Interview Questions and Answers

Updated 5 Feb 2024
Popular Designations

Q1. Unique Frequency Problem Statement

Given a string 'STR' with lowercase letters, determine the minimum number of deletions required to ensure that every letter in the string appears a unique number of times.

Exa...read more

Ans.

The task is to find the minimum number of deletions needed in a string to ensure each character appears a unique number of times.

  • Iterate through the string and count the frequency of each character

  • Track the frequencies in a hashmap

  • Identify the characters with duplicate frequencies and calculate the minimum deletions needed

  • Return the minimum number of deletions for each test case

Add your answer

Q2. Longest Switching Subarray Problem Statement

Determine the length of the longest contiguous subarray in a given array of positive integers, where the subarray qualifies as 'switching'. An array is defined as sw...read more

Ans.

Find the length of the longest switching subarray in a given array of positive integers.

  • Iterate through the array and keep track of the longest switching subarray found so far.

  • Check if the numbers at even and odd positions are identical to determine a switching subarray.

  • Return the length of the longest switching subarray.

  • Example: For input [1, 4, 1, 4, 3, 2, 3, 0], the longest switching subarray is [1, 4, 1, 4] with length 4.

Add your answer

Q3. Palindrome Linked List Detection

Given a singly linked list of integers, determine if it is a palindrome. A linked list is considered a palindrome if it reads the same forward and backward.

Example:

Input:
The ...read more
Ans.

Check if a singly linked list is a palindrome by comparing elements from both ends.

  • Traverse the linked list to find the middle point

  • Reverse the second half of the linked list

  • Compare the first half with the reversed second half to check for palindrome

  • Example: Input: 1 2 3 2 1 -1, Output: true

Add your answer

Q4. Travelling Salesman Problem

Given a list of cities numbered from 0 to N-1 and a matrix DISTANCE consisting of 'N' rows and 'N' columns, representing the distances between each pair of cities, find the shortest ...read more

Add your answer
Discover HCL Group interview dos and don'ts from real experiences

Q5. Sliding Maximum Problem Statement

Given an array of integers ARR of length 'N' and a positive integer 'K', find the maximum elements for each contiguous subarray of size K.

Example:

Input:
ARR = [3, 4, -1, 1, 5...read more
Ans.

Implement a function to find maximum elements for each contiguous subarray of size K in an array of integers.

  • Iterate through the array and maintain a deque to store the indices of elements in decreasing order.

  • Pop elements from the deque that are out of the current window and add the maximum element to the result array.

  • Return the result array containing maximum elements for each subarray of size K.

Add your answer

Q6. Longest Substring with At Most K Distinct Characters

Given a string S of length N and an integer K, find the length of the longest substring that contains at most K distinct characters.

Input:

The first line co...read more
Ans.

Find the length of the longest substring with at most K distinct characters in a given string.

  • Use a sliding window approach to keep track of the characters and their counts in the substring.

  • Maintain a hashmap to store the characters and their frequencies within the window.

  • Update the window size and characters count as you iterate through the string.

  • Keep track of the longest substring length with at most K distinct characters.

  • Return the length of the longest substring for each...read more

Add your answer
Are these interview questions helpful?

Q7. Interval List Intersection Problem

You are provided with two sorted lists of closed intervals, INTERVAL1 and INTERVAL2. A closed interval [x, y] (x < y) signifies the set of real numbers z such that x <= z <= y...read more

Ans.

Find the intersections of two sorted lists of closed intervals.

  • Iterate through both interval lists to find intersections

  • Compare the intervals and find the common range

  • Handle cases where there is no intersection between intervals

Add your answer

Q8. Stack using Two Queues Problem Statement

Develop a Stack Data Structure to store integer values using two Queues internally.

Your stack implementation should provide these public functions:

Explanation:

1. Cons...read more
Ans.

Implement a stack using two queues to store integer values with specified functions.

  • Use two queues to simulate stack operations efficiently.

  • Maintain one queue for storing elements and another for temporary storage during push operation.

  • Ensure proper handling of edge cases like empty stack or invalid operations.

  • Example: Push operation involves transferring elements from one queue to another before adding the new element.

  • Example: Pop operation removes and returns the top elemen...read more

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. 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
Ans.

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

Add your answer

Q10. Maximum Non-Adjacent Subsequence Sum

Given an array of integers, determine the maximum sum of a subsequence without choosing adjacent elements in the original array.

Input:

The first line consists of an integer...read more
Ans.

Find the maximum sum of a subsequence without choosing adjacent elements in an array.

  • Use dynamic programming to keep track of the maximum sum at each index, considering whether to include or exclude the current element.

  • At each index, the maximum sum is either the sum of the current element and the sum two positions back, or the sum at the previous index.

  • Iterate through the array and update the maximum sum accordingly.

  • Example: For input [3, 2, 7, 10], the maximum non-adjacent ...read more

Add your answer

Q11. Detect and Remove Loop in Linked List

For a given singly linked list, identify if a loop exists and remove it, adjusting the linked list in place. Return the modified linked list.

Expected Complexity:

Aim for a...read more

Ans.

Detect and remove loop in a singly linked list in place with O(n) time complexity and O(1) space complexity.

  • Use Floyd's Cycle Detection Algorithm to identify the loop in the linked list.

  • Once the loop is detected, use two pointers to find the start of the loop.

  • Adjust the pointers to remove the loop and return the modified linked list.

Add your answer

Q12. Left View of a Binary Tree Problem Statement

Given a binary tree, your task is to print the left view of the tree.

Example:

Input:
The input will be in level order form, with node values separated by a space. U...read more
Ans.

Print the left view of a binary tree given in level order form.

  • Traverse the tree level by level and print the first node encountered at each level

  • Use a queue to perform level order traversal

  • Keep track of the current level and the maximum level seen so far

Add your answer

More about working at American Express

Top Rated Large Company - 2024
Top Rated Company for Women - 2024
Top Rated Financial Services Company - 2024
HQ - New York City,New York, United States
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Intern Interview Questions from Similar Companies

3.5
 • 50 Interview Questions
4.0
 • 16 Interview Questions
3.6
 • 14 Interview Questions
3.4
 • 13 Interview Questions
3.7
 • 12 Interview Questions
3.7
 • 10 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter