Smallest Adjacent Concatenation
Reported by candidates from IDFC's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The data structure this IDFC problem hinges on is almost embarrassingly simple: the input array itself, plus one running minimum. Reported in July 2026, Smallest Adjacent Concatenation looks like a string puzzle but it's a single linear scan. You walk the array two elements at a time, glue the decimal strings together, and keep the smallest result. The odd-length tail is the only wrinkle. If you blank on the day, StealthCoder sits invisibly on your screen and gives you the solution in real time. Most people won't need it here, but it's a cheap hedge.
The problem
You are given an array arr of positive integers. Group the array into fixed adjacent pairs: (arr[0], arr[1]), (arr[2], arr[3]), and so on. For each complete pair, concatenate the decimal representation of the first number with the decimal representation of the second number, without reordering either number. If the array has odd length, treat the final unpaired number as its own candidate. Return the smallest candidate value. Function smallestAdjacentConcatenation(arr: int[]) → int Examples Example 1 arr = [15,24,34,10,12,21,45,67] return = 1221 The fixed adjacent pairs produce 1524, 3410, 1221, and 4567. The smallest value is 1221. Example 2 arr = [9,87,6] return = 6 The complete pair produces 987. The unpaired final value 6 is also a candidate and is smaller. Constraints 1 <= arr.length <= 10^5 1 <= arr[i] <= 10^4
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is that you never need a heap, a sort, or a hash table. Pairs are fixed, so there are at most n/2 + 1 candidates and one pass with a running minimum does it. Build each candidate by concatenating str(a) and str(b), then convert back to an integer, or compute a * 10^digits(b) + b to skip string work. With values up to 10^4, a pair is at most 8 digits, so it fits in a 32-bit int comfortably. The common pitfall is comparing candidates as strings, which breaks because "6" > "1221" lexicographically. Compare as integers. The other pitfall is forgetting the unpaired last element when length is odd, as in [9,87,6] where 6 beats 987. Don't sort or reorder the numbers, since the order inside each pair is fixed. Complexity is O(n) time and O(1) extra space. If the live OA rattles you, StealthCoder is the safety net.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Smallest Adjacent Concatenation cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass IDFC's OA.
IDFC reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Smallest Adjacent Concatenation FAQ
How hard is Smallest Adjacent Concatenation really?+
Easy. It's a single pass over the array with a running minimum. The only thing that trips people is the odd-length leftover element and comparing as strings instead of integers. If you can write a for loop with a step of 2, you can solve it.
What's the trick to the IDFC version of this problem?+
There isn't a deep one. Pairs are fixed, so just iterate i by 2, concatenate arr[i] and arr[i+1], convert to int, and track the minimum. If i is the last index, use arr[i] alone as a candidate. Compare numerically, never lexicographically.
Should I concatenate with strings or math?+
Either works. Strings are simpler: int(str(a) + str(b)). The math way multiplies a by 10 for each digit in b, then adds b. With values up to 10^4 and 10^5 elements, both run fast. Pick whichever you can write without bugs under pressure.
What edge cases should I test before submitting?+
Test a single-element array, which should return that element. Test odd length like [9,87,6] where the leftover wins. Test pairs where the second number has more digits than the first. Also check that you compare integers, since 6 is smaller than 987 numerically.
How do I prepare for this in 48 hours?+
Don't over-prep this one. Practice array traversal with a step of 2, string-to-int conversion, and tracking a minimum. Then spend your time on harder OA topics like sliding window, hash maps, and basic dynamic programming, since the rest of the assessment likely won't be this gentle.