IBM ASE Coding Questions Hackerrank 2025

0
138
IBM ASE Coding Questions Hackerrank 2025
IBM ASE Coding Questions Hackerrank 2025
Telegram Group Join Now
Instagram Page Join Now
whatsApp Channel Join Now
Rate this post

IBM ASE Coding Questions Hackerrank 2025-2026 | IBM Associate System Engineer coding questions hackerrank 2025: Are you preparing for the IBM Associate System Engineer (ASE) 2025 off-campus drive or ibm cic ase coding questions? One of the most common rounds is the HackerRank coding assessment, where you are tested on data structures, problem-solving skills, and clean code writing.

In this post, we’ll go through a realistic sample coding question that has appeared in previous IBM ASE HackerRank rounds.
This will help you understand the difficulty level, logic building, and expected coding standards for the exam.

Question 1: IBM Associate System Engineer coding questions hackerrank

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

Example 1:

Input: L1 = [2,4,3], L2 = [5,6,4]
Output: [7,0,8]
Explanation: 342 + 465 = 807.

Example 2:

Input: L1 = [0], L2 = [0]
Output: [0]

Example 3:

Input: L1 = [9,9,9,9,9,9,9], L2 = [9,9,9,9]
Output: [8,9,9,9,0,0,0,1]

Constraints:

  • The number of nodes in each linked list is in the range [1, 100].
  • 0 <= Node.val <= 9
  • It is guaranteed that the list represents a number that does not have leading zeros.

Python Solution

# Definition for singly-linked list.
class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next

def addTwoNumbers(l1, l2):
    dummy = ListNode()
    current = dummy
    carry = 0

    while l1 or l2 or carry:
        val1 = l1.val if l1 else 0
        val2 = l2.val if l2 else 0

        total = val1 + val2 + carry
        carry = total // 10
        current.next = ListNode(total % 10)
        current = current.next

        if l1: l1 = l1.next
        if l2: l2 = l2.next

    return dummy.next

Approach Explained

  • We iterate through both linked lists node by node.
  • We add corresponding digits plus carry from the previous addition.
  • We create a new node for each sum digit and attach it to the result list.
  • We continue this until both lists are exhausted and carry becomes zero.

Question 2: IBM ASE Coding Questions Hackerrank 2025 | Ibm cic ase coding questions

Problem Statement: You are given a string s containing just the characters '(', ')', '{', '}', '[', and ']'.

Determine if the input string is valid.

A string is considered valid if:

  1. Every open bracket must be closed by the same type of bracket.
  2. Open brackets must be closed in the correct order (proper nesting).
  3. Every close bracket must have a corresponding open bracket of the same type.

Example Test Cases

Example 1:

Input: s = "()"
Output: true

Example 2:

Input: s = "()[]{}"
Output: true

Example 3:

Input: s = "(]"
Output: false

Example 4:

Input: s = "([])"
Output: true

Example 5:

Input: s = "([)]"
Output: false

Constraints

  • 1 <= s.length <= 10^4
  • s consists of only these characters: '()[]{}'

Python Solution

def isValid(s: str) -> bool:
    stack = []
    mapping = {')': '(', '}': '{', ']': '['}

    for char in s:
        if char in mapping.values():  # opening brackets
            stack.append(char)
        else:  # closing brackets
            if not stack or stack[-1] != mapping[char]:
                return False
            stack.pop()

    return len(stack) == 0

Approach Explanation

  • Use a stack to track opening brackets.
  • When you find a closing bracket, check if the top of the stack has the matching opening bracket.
  • If it matches, pop it; if it doesn’t, return False.
  • In the end, if the stack is empty → the string is valid.

Check Other IBM coding Question below:

LEAVE A REPLY

Please enter your comment!
Please enter your name here