thecodingcompany
Programming

C / C++ coding practice

Core to campus coding rounds and embedded, systems and gaming roles.

Exercises6
FormatPrompt + hint

6 exercises

Try each one before reading the hint. If you finish without using the hint, move on; if the hint is not enough, work the neighbouring DSA pattern.

01Reverse a linked list
TaskReverse a singly linked list iteratively and return the new head.
HintMaintain prev, curr and next pointers; move curr forward while relinking to prev.
02Detect a cycle in a linked list
TaskDetermine whether a linked list has a cycle using constant extra space.
HintFloyd's tortoise and hare: advance one pointer by one node and another by two.
03Swap two numbers without a temporary variable
TaskSwap two integers using only arithmetic or XOR.
Hinta = a + b; b = a − b; a = a − b — or use XOR three times.
04String reversal in place
TaskReverse a C string in place without allocating a new buffer.
HintTwo indices moving inward, swapping characters until they meet.
05Check for a balanced bracket string
TaskVerify that brackets of all three kinds are correctly nested and closed.
HintPush openers on a stack; on a closer, pop and check for the matching type.
06Count set bits
TaskCount the number of 1 bits in an integer.
HintRepeatedly do n = n & (n − 1) and count iterations — it runs once per set bit.

Practise here. Get placed there.

Prep+ is unlimited practice. When you are ready to turn it into an offer, TCC Placement Partner handles portfolio, resume and interviews.