HCL Technologies Interview Preparation

55+ coding, technical, system design and HR questions with complete solutions for freshers.

QuestionAnswerCategory
Q1. Write program to count frequency of each character.Use hashmap to store character counts while iterating through string.
def count_char_frequency(s):
    freq = {}
    for char in s:
        freq[char] = freq.get(char, 0) + 1
    return freq

# Example
print(count_char_frequency("hello"))  # {'h': 1, 'e': 1, 'l': 2, 'o': 1}
Coding
Q2. Reverse a linked list.Maintain three pointers: prev, current, next. Reverse direction of links iteratively.
class Node:
    def __init__(self, data):
        self.data = data
        self.next = None

def reverse_list(head):
    prev, curr = None, head
    while curr:
        next_temp = curr.next
        curr.next = prev
        prev = curr
        curr = next_temp
    return prev
Coding
Q3. Find first non-repeating character from stream of characters.Use hashmap with indexes, track characters seen. Return first non-repeating.
def first_non_repeating(s):
    freq = {}
    for char in s:
        freq[char] = freq.get(char, 0) + 1
    for char in s:
        if freq[char] == 1:
            return char
    return None

# Example
print(first_non_repeating("hello"))  # 'h'
Coding
Q4. Design a URL shortener system.Use hash function for mapping long URLs to short codes. Store in database with TTL. Scale with cache and load balancing.System Design
Q5. Implement LRU Cache.Use HashMap + Doubly Linked List. HashMap for O(1) access, DLL for maintaining order.
from collections import OrderedDict

class LRUCache:
    def __init__(self, capacity):
        self.cache = OrderedDict()
        self.capacity = capacity
    
    def get(self, key):
        if key not in self.cache:
            return -1
        self.cache.move_to_end(key)
        return self.cache[key]
    
    def put(self, key, value):
        if key in self.cache:
            self.cache.move_to_end(key)
        self.cache[key] = value
        if len(self.cache) > self.capacity:
            self.cache.popitem(last=False)
Coding
Q6. What is database indexing?Indexing creates data structure (usually B-tree) for faster data retrieval. Trade-off: faster reads, slower writes, more storage.Technical
Q7. Design a messaging system like WhatsApp.Message queue (Kafka), WebSocket for real-time, database for persistence, cache for active conversations.System Design
Q8. Two Sum problem.Use hashmap: store target-num as key, check if current num exists in map.
def two_sum(nums, target):
    seen = {}
    for num in nums:
        complement = target - num
        if complement in seen:
            return [seen[complement], nums.index(num)]
        seen[num] = nums.index(num)
    return []

# Example
print(two_sum([2, 7, 11, 15], 9))  # [0, 1]
Coding
Q9. How does REST API differ from GraphQL?REST: fixed endpoints, multiple requests for related data. GraphQL: single endpoint, query what you need, no over/under-fetching.Technical
Q10. Longest substring without repeating characters.Use sliding window with hashmap to track character positions.
def length_of_longest_substring(s):
    char_index = {}
    max_len = 0
    start = 0
    for i, char in enumerate(s):
        if char in char_index:
            start = max(start, char_index[char] + 1)
        char_index[char] = i
        max_len = max(max_len, i - start + 1)
    return max_len

# Example
print(length_of_longest_substring("abcabcbb"))  # 3
Coding
Q11. Explain TCP vs UDP.TCP: reliable, ordered, connection-oriented. UDP: faster, connectionless, unreliable. Used for video streaming, gaming.Technical
Q12. Merge two sorted arrays.Use two pointers, compare elements, add smaller to result.
def merge_sorted_arrays(arr1, arr2):
    result = []
    i = j = 0
    while i < len(arr1) and j < len(arr2):
        if arr1[i] <= arr2[j]:
            result.append(arr1[i])
            i += 1
        else:
            result.append(arr2[j])
            j += 1
    result.extend(arr1[i:])
    result.extend(arr2[j:])
    return result

# Example
print(merge_sorted_arrays([1, 3, 5], [2, 4, 6]))  # [1, 2, 3, 4, 5, 6]
Coding
Q13. What is deadlock? How to prevent it?Deadlock: circular wait for resources. Prevention: break one of four conditions (mutual exclusion, hold & wait, no preemption, circular wait).Technical
Q14. Group anagrams together.Sort characters in each word, use sorted string as key in hashmap.
def group_anagrams(words):
    groups = {}
    for word in words:
        sorted_word = ''.join(sorted(word))
        if sorted_word not in groups:
            groups[sorted_word] = []
        groups[sorted_word].append(word)
    return list(groups.values())

# Example
print(group_anagrams(['listen', 'silent', 'hello', 'world']))
Coding
Q15. Design a parking lot system.Multiple levels, different vehicle types, payment system. Use state machine for spot status.System Design
Q16. Missing number in array.Use expected sum minus actual sum formula or XOR operation.
def find_missing_number(nums):
    n = len(nums)
    expected_sum = n * (n + 1) // 2
    actual_sum = sum(nums)
    return expected_sum - actual_sum

# Example
print(find_missing_number([3, 0, 1]))  # 2
Coding
Q17. What are transactions in database?Unit of work with ACID properties. Ensures data consistency. Can commit or rollback.Technical
Q18. Implement queue using two stacks.Stack1 for push, Stack2 for pop. Transfer elements when popping if Stack2 is empty.
class QueueUsingStacks:
    def __init__(self):
        self.stack1 = []
        self.stack2 = []
    
    def enqueue(self, x):
        self.stack1.append(x)
    
    def dequeue(self):
        if not self.stack2:
            while self.stack1:
                self.stack2.append(self.stack1.pop())
        return self.stack2.pop() if self.stack2 else None
Coding
Q19. What is multithreading?Ability to execute multiple threads simultaneously. Improves performance. Requires synchronization for shared resources.Technical
Q20. Maximum subarray sum (Kadane's algorithm).Track current sum, reset if negative. Update max at each step.
def max_subarray_sum(arr):
    max_sum = current_sum = arr[0]
    for num in arr[1:]:
        current_sum = max(num, current_sum + num)
        max_sum = max(max_sum, current_sum)
    return max_sum

# Example
print(max_subarray_sum([-2, 1, -3, 4, -1, 2, 1, -5, 4]))  # 6
Coding
Q21. Tell me about yourself.Brief intro: education, relevant projects, internships, skills, why HCL. Keep concise.HR
Q22. Why HCL Technologies?Company reputation, innovation, global presence, career growth opportunities.HR
Q23. Your strengths and weaknesses.Strengths: problem-solving, quick learner. Weakness: showing improvement.HR
Q24. How do you handle pressure?Stay calm, prioritize, communicate, break into smaller tasks.HR
Q25. Team collaboration experience.Use STAR method. Emphasize communication, listening, compromise.HR
Q26. Rotate matrix 90 degrees.Transpose + reverse each row. Or use layer by layer approach.
def rotate_matrix(matrix):
    n = len(matrix)
    # Transpose
    for i in range(n):
        for j in range(i, n):
            matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
    # Reverse each row
    for row in matrix:
        row.reverse()
    return matrix
Coding
Q27. Design a search engine (Google).Web crawler, indexer, ranking algorithm, cache layer, distributed architecture.System Design
Q28. Number of islands (BFS/DFS).Traverse grid, mark visited cells, count disconnected components.
def num_islands(grid):
    def dfs(i, j):
        if i < 0 or i >= len(grid) or j < 0 or j >= len(grid[0]) or grid[i][j] == '0':
            return
        grid[i][j] = '0'
        dfs(i+1, j)
        dfs(i-1, j)
        dfs(i, j+1)
        dfs(i, j-1)
    
    count = 0
    for i in range(len(grid)):
        for j in range(len(grid[0])):
            if grid[i][j] == '1':
                dfs(i, j)
                count += 1
    return count
Coding
Q29. Intersection of two linked lists.Use two pointers traversing both lists. When one reaches end, switch to other list.
def get_intersection_node(headA, headB):
    if not headA or not headB:
        return None
    pA, pB = headA, headB
    while pA != pB:
        pA = pA.next if pA else headB
        pB = pB.next if pB else headA
    return pA
Coding
Q30. Median of two sorted arrays.Use binary search on smaller array to find partition point.Coding
Q31. Valid parentheses expression.Use stack to match opening and closing brackets.
def is_valid(s):
    stack = []
    mapping = {')': '(', '}': '{', ']': '['}
    for char in s:
        if char in mapping:
            if not stack or stack[-1] != mapping[char]:
                return False
            stack.pop()
        else:
            stack.append(char)
    return len(stack) == 0
Coding
Q32. Word ladder (BFS).BFS from start word, generate next words by changing one letter, find shortest path.Coding
Q33. Coin change problem.Dynamic programming. dp[i] = minimum coins needed for amount i.
def coin_change(coins, amount):
    dp = [float('inf')] * (amount + 1)
    dp[0] = 0
    for i in range(1, amount + 1):
        for coin in coins:
            if coin <= i:
                dp[i] = min(dp[i], dp[i - coin] + 1)
    return dp[amount] if dp[amount] != float('inf') else -1
Coding
Q34. Longest increasing subsequence.Dynamic programming or binary search approach. O(n log n) with binary search.Coding
Q35. Edit distance (Levenshtein).DP: table[i][j] represents edits needed to convert first i chars to first j chars.Coding
Q36. Serialize/deserialize binary tree.Use preorder traversal with markers for null nodes. Reconstruct by reversing process.Coding
Q37. LCA of binary tree.Recursively search left and right subtrees. Return node if found in current or both subtrees.Coding
Q38. Trap rainwater.Use two pointers or DP. At each position, water = min(max_left, max_right) - height.Coding
Q39. Merge k sorted lists.Use heap (priority queue) to efficiently get minimum element each time.Coding
Q40. Sliding window maximum.Use deque to maintain indices of useful elements in decreasing order.Coding
Q41. Implement Trie (Prefix Tree).TrieNode with children dict/array. Insert, search, startsWith operations.
class TrieNode:
    def __init__(self):
        self.children = {}
        self.is_end = False

class Trie:
    def __init__(self):
        self.root = TrieNode()
    
    def insert(self, word):
        node = self.root
        for char in word:
            if char not in node.children:
                node.children[char] = TrieNode()
            node = node.children[char]
        node.is_end = True
    
    def search(self, word):
        node = self.root
        for char in word:
            if char not in node.children:
                return False
            node = node.children[char]
        return node.is_end
Coding
Q42. Word break problem.DP where dp[i] = True if word[:i] can be segmented from dictionary.Coding
Q43. Permutations of string.Backtracking: fix each character at position, recursively permute rest.Coding
Q44. N-Queens problem.Backtracking. Place queens row by row, check if placement valid, backtrack if not.Coding
Q45. Graph bipartite coloring.Use BFS/DFS to color graph with 2 colors. Return false if adjacent nodes have same color.Coding
Q46. Topological sort (Kahn's algorithm).Calculate in-degree for each node. Process nodes with in-degree 0, reduce neighbors's in-degree.Coding
Q47. Dijkstra shortest path.Use priority queue, process nodes in order of distance, update neighbors.Coding
Q48. Implement hash map with collision handling.Open addressing or chaining for collision resolution. Load factor management.Coding
Q49. Salary expectations?Research market rates. Give range based on location, experience, skills.HR
Q50. Where do you see yourself in 5 years?Show growth mindset. Senior developer, technical lead, or specialist role.HR
Q51. Do you have questions for us?Ask about team, culture, tech stack, growth opportunities, or company vision.HR
Q52. How do you stay updated with technology?Online courses, blogs, GitHub, coding platforms, tech conferences.HR
Q53. Describe conflict with colleague, how resolved.Use STAR. Focus on professional resolution, listening, mutual understanding.HR
Q54. Why did you leave previous job?Focus on growth, learning, new challenges. Avoid negativity about company/people.HR
Q55. Any questions about company/role?Show genuine interest. Ask about projects, team size, learning opportunities.HR