HCL Previous Year Coding Questions & Resources

If you’re aiming for a career in IT, HCL Technologies should definitely be on your radar.
HCL (Hindustan Computers Limited) is one of India’s top tech giants with a presence in over 50 countries. Known for innovation, growth opportunities, and employee-first culture , it’s a dream destination for many freshers and experienced developers alike.

But cracking an HCL job requires understanding its recruitment process, test pattern, and interview expectations.

Let’s go step by step 👇

HCL Hiring Process (2025)

Here’s how HCL typically conducts its fresher and early-career hiring process.
The steps may slightly vary across campuses or job roles, but this is the general flow:

StageWhat HappensWhat They’re Looking For
1. Application

/ Resume Submission

Apply through the official HCL Careers Portal or campus placements.Clear formatting, relevant skills, and project highlights.
2. Resume ShortlistingRecruiters screen profiles based on eligibility and skill match.Consistent academic record (60%+), no active backlogs.
3. Online

/ Written Test

Combination of aptitude, reasoning, verbal, technical MCQs, and coding problems.Logical thinking, basic programming, and accuracy.
4. Communication

/ GD Round (optional)

Group discussion or JAM to assess communication skills.Clarity, confidence, and teamwork.
5. Technical InterviewCovers coding, DSA, projects, OS, DBMS, and networking concepts.Problem-solving skills and conceptual understanding.
6. HR InterviewFocus on personality, motivation, strengths, and fit.Positive attitude and cultural alignment.
7. Offer & OnboardingYou receive an offer letter and onboarding instructions.Verify details and confirm your joining date.

Average Timeline: 2–4 weeks from application to final offer.
Used platforms: AMCAT, Cocubes, HackerRank, or in-house HCL platform.

Online Test Pattern Overview

Total Duration: ~90–95 minutes
Question Sections:

  1. Quantitative Aptitude – Percentages, time & work, profit/loss, number systems
  2. Logical Reasoning – Series, coding-decoding, data interpretation
  3. Verbal Ability – Grammar, comprehension, sentence correction
  4. Technical MCQs – C, C++, Java, DBMS, OS, networking basics
  5. Coding Section – 1 or 2 real-world problems (string, array, number-based)

HCL Coding Round — What to Expect

Coding problems usually test your ability to write clean, efficient logic under time constraints.
Common topics include:

  • Arrays and Strings
  • Mathematical logic (GCD, Armstrong, Perfect number)
  • Pattern generation
  • Simple recursion and loops
  • File handling (sometimes for experienced roles)

For hands-on practice: Use👇

Technical Interview Focus Areas

  • Programming Languages: C, C++, Java, or Python
  • Data Structures: Arrays, Linked Lists, Stacks, Queues
  • Algorithms: Sorting, Searching, Recursion basics
  • Database Concepts: SQL, Joins, Normalization
  • Operating Systems: Threads, Scheduling, Deadlocks
  • Computer Networks: OSI Model, TCP/IP, IP addressing
  • Project Discussion: Expect detailed questions on your final year project

    Pro Tip: Be honest about what you know. Interviewers prefer clarity over guesswork.

HR Interview Tips

This is where your soft skills and mindset shine.
Common questions:

  • Tell me about yourself.
  • Why HCL?
  • Where do you see yourself in 5 years?
  • What are your strengths and weaknesses?
  • Are you open to relocation and shifts?

Complete HR Interview Questions

Be confident and align your answers with HCL’s values: innovation, teamwork, and growth.

Resources to Prepare for HCL

Here are the best places to start your preparation:


HCL Previous Year Coding Questions

Below is a detailed list of HCL previous-year coding questions frequently asked in online assessments, campus drives, and interviews.
Each question includes a problem statement, input/output format, constraints, and sample explanation.

1. Smallest Substring with All Distinct Characters

Problem Statement:
Given a string s, find the length of the smallest substring that contains all the distinct characters of s.
You need to identify the minimum window that includes every unique character present in the original string.

Input Format:

  • A single string s (consisting of lowercase English letters)

Output Format:

  • An integer representing the length of the smallest substring

Constraints:

  • 1 ≤ |s| ≤ 10⁴

Example:
Input: abcda
Output: 4
Explanation: The substring abcd contains all unique characters.

2. Valid Parentheses

Problem Statement:
Given a string containing only the characters '(', ')', '{', '}', '[', and ']', determine if the input string is valid.
A string is valid if brackets are closed in the correct order and properly nested.

Input Format:

  • A single string of brackets

Output Format:

  • "Valid" if properly nested, otherwise "Invalid"

Constraints:

  • 1 ≤ |s| ≤ 10⁵

Example:
Input: ({[]})
Output: Valid

3. Prime or Lowest Divisor

Problem Statement:
Given a number n, check if it is a prime number.
If it is prime, print 1. If not, print the smallest divisor greater than 1.

Input Format:

  • An integer n

Output Format:

  • 1 if prime, else the smallest divisor

Constraints:

  • 2 ≤ n ≤ 10⁶

Example:
Input: 10
Output: 2

4. Array Equalization by Operations

Problem Statement:
Given an array of integers, determine whether all elements can be made equal by repeatedly adding or subtracting the same integer x to any subset of elements.

Input Format:

  • An integer array arr

Output Format:

  • "Yes" if all can be made equal, else "No"

Constraints:

  • 1 ≤ N ≤ 10⁵
  • |arr[i]| ≤ 10⁹

Example:
Input: [1, 5, 7]
Output: Yes

5. Count Pairs with Given Sum

Problem Statement:
Given an array of integers and a target sum, count how many pairs of elements in the array add up to the target.

Input Format:

  • An integer array arr
  • Integer sum

Output Format:

  • Number of pairs that sum up to sum

Example:
Input: arr = [1, 5, 7, -1, 5], sum = 6
Output: 3
Explanation: Pairs are (1,5), (7,-1), (1,5).

6. First Non-Repeating Character

Problem Statement:
Given a string, find the first character that does not repeat.

Input Format:

  • A single string s

Output Format:

  • The first non-repeating character, or -1 if all repeat.

Example:
Input: aabbcd
Output: c

7. Second Largest Element in Array

Problem Statement:
Find the second largest element in the given integer array.

Input Format:

  • An array arr of integers

Output Format:

  • The second largest element

Constraints:

  • Array must contain at least two distinct elements

Example:
Input: [2, 4, 5, 1, 3]
Output: 4

8. Reverse Words in a Sentence

Problem Statement:
Given a sentence, reverse the order of words without reversing individual characters.

Input Format:

  • A single line string containing words separated by spaces

Output Format:

  • A new string with word order reversed

Example:
Input: I love coding
Output: coding love I

9. Palindrome String

Problem Statement:
Determine whether a given string is a palindrome (reads the same forwards and backwards). Ignore case.

Input Format:

  • A single string

Output Format:

  • "Palindrome" or "Not Palindrome"

Example:
Input: Level
Output: Palindrome

10. Sum of Digits Until Single Digit

Problem Statement:
Given an integer n, repeatedly add all its digits until the result is a single digit.

Input Format:

  • A positive integer n

Output Format:

  • A single digit result

Example:
Input: 9875
Output: 2
(9+8+7+5=29 → 2+9=11 → 1+1=2)

11. Check Anagram

Problem Statement:
Given two strings, determine if they are anagrams (contain the same characters in different order).

Input Format:

  • Two strings s1 and s2

Output Format:

  • "Yes" or "No"

Example:
Input: listen, silent
Output: Yes

12. Rotate Array by K Positions

Problem Statement:
Rotate an array to the right by k positions.

Input Format:

  • An array arr
  • An integer k

Output Format:

  • The rotated array

Example:
Input: [1, 2, 3, 4, 5], k = 2
Output: [4, 5, 1, 2, 3]

v# 13. Armstrong Number

Problem Statement:
A number is an Armstrong number if the sum of its digits raised to the power of the number of digits equals the number itself.

Input Format:

  • A positive integer n

Output Format:

  • "Yes" or "No"

Example:
Input: 153
Output: Yes
(1³ + 5³ + 3³ = 153)

14. Find Missing Number

Problem Statement:
Given n-1 integers from 1 to n, find the missing number.

Input Format:

  • Array of size n-1

Output Format:

  • Missing integer

Example:
Input: [1, 2, 4, 5]
Output: 3

15. Diagonal Difference (Matrix)

Problem Statement:
Given a square matrix, find the absolute difference between the sums of its primary and secondary diagonals.

Input Format:

  • An n x n matrix

Output Format:

  • Absolute integer difference

Example:
Input:

1 2 3
4 5 6
9 8 9

Output: 2

16. Strong Number

Problem Statement:
A number is called a “Strong Number” if the sum of the factorials of its digits equals the number itself.

Input Format:

  • A positive integer n

Output Format:

  • "Yes" or "No"

Example:
Input: 145
Output: Yes
(1! + 4! + 5! = 145)

17. GCD of Two Numbers

Problem Statement:
Compute the greatest common divisor (GCD) of two positive integers.

Input Format:

  • Two integers a, b

Output Format:

  • The GCD value

Example:
Input: 54 24
Output: 6

18. Count Frequency of Elements

Problem Statement:
Given an array, print the frequency of each distinct element.

Input Format:

  • An array of integers

Output Format:

  • Each element followed by its count

Example:
Input: [1, 2, 2, 3, 1, 4]
Output:

1 -> 2
2 -> 2
3 -> 1
4 -> 1

19. Convert Roman to Integer

Problem Statement:
Convert a Roman numeral string to its integer value.

Input Format:

  • A valid Roman numeral string

Output Format:

  • The integer equivalent

Example:
Input: XIV
Output: 14

20. Sort Characters by Frequency

Problem Statement:
Rearrange the characters of a string so that they appear in descending order of frequency.

Input Format:

  • A string s

Output Format:

  • Rearranged string

Example:
Input: tree
Output: eetr

21. Sum of Array Except Self

Problem Statement:
Given an array of integers, create a new array where each element at index i is the sum of all elements except the one at i.

Input Format:

  • An integer array arr

Output Format:

  • A new array of the same length

Example:
Input: [1, 2, 3]
Output: [5, 4, 3]
Explanation: For index 0 → 2+3=5, index 1 → 1+3=4, index 2 → 1+2=3


22. String Compression

Problem Statement:
Given a string, compress it using counts of repeated characters.
For example, aaabbc becomes a3b2c1.

Input Format:

  • A single string s

Output Format:

  • A compressed string

Constraints:

  • 1 ≤ |s| ≤ 10⁵

Example:
Input: aaabbc
Output: a3b2c1


23. Replace Spaces with Hyphens

Problem Statement:
Replace all spaces in a string with hyphens (-).

Input Format:

  • A single line string

Output Format:

  • Modified string

Example:
Input: HCL Technologies
Output: HCL-Technologies


24. Count Vowels and Consonants

Problem Statement:
Write a program to count the number of vowels and consonants in a given string.
Ignore digits and special characters.

Input Format:

  • A single string

Output Format:

  • Two integers: number of vowels and consonants

Example:
Input: hello world
Output: Vowels: 3, Consonants: 7

25. Factorial of a Number

Problem Statement:
Find the factorial of a given non-negative integer n.

Input Format:

  • An integer n

Output Format:

  • The factorial value

Constraints:

  • 0 ≤ n ≤ 20

Example:
Input: 5
Output: 120

26. Check Perfect Number

Problem Statement:
A number is perfect if it equals the sum of its proper divisors (excluding itself).
Check if the given number is perfect.

Input Format:

  • Integer n

Output Format:

  • "Yes" or "No"

Example:
Input: 28
Output: Yes
Explanation: Divisors are 1, 2, 4, 7, 14 → sum = 28

27. Leap Year Checker

Problem Statement:
Determine whether a given year is a leap year or not.

Input Format:

  • Integer year y

Output Format:

  • "Leap Year" or "Not Leap Year"

Example:
Input: 2020
Output: Leap Year

28. Reverse Number

Problem Statement:
Reverse the digits of a given integer.

Input Format:

  • Integer n

Output Format:

  • Reversed number

Example:
Input: 1234
Output: 4321

29. Find Largest and Smallest Element in Array

Problem Statement:
Given an array of integers, find the largest and smallest element.

Input Format:

  • Integer array arr

Output Format:

  • Two integers representing smallest and largest

Example:
Input: [4, 9, 1, 32, 12]
Output: 1 32

30. Binary to Decimal Conversion

Problem Statement:
Convert a binary number (as a string) into its decimal equivalent.

Input Format:

  • String representing binary number

Output Format:

  • Decimal integer

Example:
Input: 1011
Output: 11

31. Decimal to Binary Conversion

Problem Statement:
Convert a decimal number into binary representation.

Input Format:

  • Integer n

Output Format:

  • Binary string

Example:
Input: 10
Output: 1010

32. Palindromic Number

Problem Statement:
Check if a given integer is a palindrome number (reads same forward and backward).

Input Format:

  • Integer n

Output Format:

  • "Yes" or "No"

Example:
Input: 121
Output: Yes

33. Remove Vowels from String

Problem Statement:
Remove all vowels (a, e, i, o, u) from a given string.

Input Format:

  • String s

Output Format:

  • Modified string without vowels

Example:
Input: education
Output: dctn

34. Count Digits in a Number

Problem Statement:
Count how many digits are in a given integer.

Input Format:

  • Integer n

Output Format:

  • Integer count

Example:
Input: 4589
Output: 4

35. Power of a Number

Problem Statement:
Compute a raised to the power b without using built-in power functions.

Input Format:

  • Two integers a, b

Output Format:

  • The result of aᵇ

Example:
Input: 2 5
Output: 32

36. Swap Two Numbers (Without Third Variable)

Problem Statement:
Swap two numbers without using a temporary variable.

Input Format:

  • Two integers a and b

Output Format:

  • Swapped values

Example:
Input: a=5, b=10
Output: a=10, b=5

37. Check for Armstrong Numbers in a Range

Problem Statement:
Given two numbers L and R, print all Armstrong numbers in the range [L, R].

Input Format:

  • Two integers L, R

Output Format:

  • All Armstrong numbers separated by space

Example:
Input: 100 500
Output: 153 370 371 407

38. Sum of Even and Odd Elements in Array

Problem Statement:
Find the sum of all even and all odd elements in a given array.

Input Format:

  • Integer array arr

Output Format:

  • Two integers: even sum and odd sum

Example:
Input: [1,2,3,4,5,6]
Output: Even Sum = 12, Odd Sum = 9

39. Remove Duplicates from Sorted Array

Problem Statement:
Given a sorted array, remove duplicates in-place so that each element appears only once.

Input Format:

  • Sorted integer array

Output Format:

  • Array with unique elements

Example:
Input: [1,1,2,2,3,3,3,4]
Output: [1,2,3,4]

40. Find Element Occurring Once

Problem Statement:
In an array where every element appears twice except for one, find the element that appears only once.

Input Format:

  • Integer array arr

Output Format:

  • The single element

Example:
Input: [2,3,5,4,5,3,2]
Output: 4

At Last

Getting a job at HCL isn’t about luck, it’s about strategy and consistent preparation.
Focus on fundamentals, practice coding daily, and stay updated on HCL’s latest drives and job openings.

Join Telegram group for more resources & discussions!

🧰 Useful Resources for Your Placement Prep