LTIMindtree (LTM) Coding Questions 2026: Practice Set
What LTM publishes about its fresher coding round, where candidate sources disagree, and 8 original tested practice problems in Python and C++.
on this page§ 09

PapersAdda is independent and is not affiliated with LTM or LTIMindtree. Nothing here is an LTM document, and none of the problems below was asked in a real LTM test.
What LTM itself says (and what it does not)
LTM published a recruitment guide written by its talent acquisition team. It describes interviews as "structured conversations" and lists a technical round, a managerial round, an optional customer round and an HR round. For the technical round it says problem-solving strategies and thought processes are also considered. That guide is not written for freshers specifically, and it does not mention an online test or a coding section.
A second LTM guide, "Ace the Interview", says that in IT consulting roles many technical assessments involve problem-solving style and explanation ability rather than solution delivery, and it lists "explaining your approach during problem-solving" as a best practice. So the one thing LTM states in public is about how you think aloud, not about how many problems appear.
On cost, the LTM careers site says neither LTM nor its authorized recruitment agencies or partners charge any candidate registration fee or any other fees for an interview or employment. Apply only through careers.ltm.com or the mail your college placement cell forwards.
What candidate sources report, and where they split
Two candidate-facing pages, both checked on 31 October 2026, give opposite answers:
| Source (candidate-facing, not LTM) | What it says about coding |
|---|---|
| DesignGurus, "What Is the LTIMindtree Assessment Test Pattern?" | Some drives include a coding section with two to four programs, at easy to medium difficulty, on arrays, strings, hash maps and lists. Languages reported: C, C++, Java and Python. |
| PlacementPreparation.io, LTIMindtree syllabus and test pattern | In most recent drives LTIMindtree no longer includes coding questions; the focus is computer science multiple-choice questions. |
PapersAdda's existing guides give still other numbers for the coding block, and they are all candidate-reported too: see the LTIMindtree recruitment process, placement papers and syllabus pages. The honest reading is that the coding section varies by drive and platform. Your drive mail is the only authority for your sitting.
What to do with that: practise coding anyway. If your drive has no coding block, the same habits (tracing a loop, spotting an off-by-one, reading output) are what the multiple-choice technical questions test.
Topic plan: which DSA topics to cover first
LTM publishes no syllabus for this section, so this order comes from the topics the DesignGurus page names (arrays, strings, hash maps and lists) plus the way the problems below build on each other.
- Arrays and single-pass scans (Problems 1, 4, 8). Learn to keep a few variables instead of sorting.
- Strings and run-length thinking (Problems 2, 6). Practise index-based walking with a start and an end pointer.
- Hash maps and sets (Problems 3, 7). The goal is replacing a nested loop with a lookup.
- Stack (Problem 5). One pattern, but it shows up in many disguises.
- Sliding window (Problem 8). Only after plain arrays feel easy.
Practice problems in the style of the LTIMindtree coding round
These eight are original and sit in the easy to medium band described by the candidate source above. Each program reads standard input and prints to standard output. Real platforms differ on input format, so adapt the reading lines to what your test screen shows.
Problem 1: Second largest distinct value
Given a list of integers, print the second largest distinct value. If every value is the same (or there is only one value), print -1.
Input format: first line n, second line n integers.
Output format: one integer.
Worked example:
Input:
5
4 9 9 2 7
Output:
7
The distinct values are 9, 7, 4 and 2, so the second largest is 7. The repeated 9 does not count twice.
Idea: keep the largest and the runner-up in two variables and update both in one pass; a value equal to the current largest is skipped.
import sys
data = sys.stdin.read().split()
n = int(data[0])
a = list(map(int, data[1:1 + n]))
first = second = None
for x in a:
if first is None or x > first:
if first is not None:
second = first
first = x
elif x != first and (second is None or x > second):
second = x
print(-1 if second is None else second)
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
bool hasFirst = false, hasSecond = false;
long long first = 0, second = 0;
for (int i = 0; i < n; i++) {
long long x;
cin >> x;
if (!hasFirst || x > first) {
if (hasFirst) { second = first; hasSecond = true; }
first = x; hasFirst = true;
} else if (x != first && (!hasSecond || x > second)) {
second = x; hasSecond = true;
}
}
cout << (hasSecond ? second : -1) << endl;
return 0;
}
Time complexity: O(n) time, O(1) extra space.
Problem 2: Longest run of one character
Given a non-empty lowercase string, find the longest block of identical consecutive characters. Print the character and the length. If two blocks tie, print the one that appears first.
Input format: one line containing the string.
Output format: the character, a space, then the length.
Worked example:
Input:
aabbbcc
Output:
b 3
The blocks are aa, bbb and cc. The longest is bbb, so the answer is b 3.
Idea: walk the string once, count the current block, and replace the best only on a strictly longer block (this keeps the earliest on a tie).
s = input().strip()
best_ch, best_len = s[0], 1
cur_len = 1
for i in range(1, len(s)):
if s[i] == s[i - 1]:
cur_len += 1
else:
cur_len = 1
if cur_len > best_len:
best_len = cur_len
best_ch = s[i]
print(best_ch, best_len)
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
char bestCh = s[0];
int bestLen = 1, curLen = 1;
for (size_t i = 1; i < s.size(); i++) {
if (s[i] == s[i - 1]) curLen++;
else curLen = 1;
if (curLen > bestLen) { bestLen = curLen; bestCh = s[i]; }
}
cout << bestCh << " " << bestLen << endl;
return 0;
}
Time complexity: O(n) time, O(1) extra space.
Problem 3: Count pairs with a given sum
Count the index pairs (i, j) with i < j and a[i] + a[j] = K. Equal values at different positions count as different pairs.
Input format: first line n and K, second line n integers.
Output format: one integer, the number of pairs.
Worked example:
Input:
5 6
1 5 3 3 3
Output:
4
The pair 1 and 5 gives one pair. The three 3s sit at three positions, and any two of them add to 6, so they give three pairs. Total 4.
Idea: before storing each value, look up how many earlier values equal K minus it; a hash map of counts makes each lookup constant time.
import sys
from collections import defaultdict
data = sys.stdin.read().split()
n, k = int(data[0]), int(data[1])
a = list(map(int, data[2:2 + n]))
seen = defaultdict(int)
count = 0
for x in a:
count += seen[k - x]
seen[x] += 1
print(count)
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
long long k;
cin >> n >> k;
unordered_map<long long, long long> seen;
long long count = 0;
for (int i = 0; i < n; i++) {
long long x;
cin >> x;
auto it = seen.find(k - x);
if (it != seen.end()) count += it->second;
seen[x]++;
}
cout << count << endl;
return 0;
}
Time complexity: O(n) average time, O(n) extra space.
Problem 4: Rotate an array to the right
Rotate the array to the right by k positions and print the result. k can be larger than n.
Input format: first line n and k, second line n integers.
Output format: the rotated array on one line, separated by spaces.
Worked example:
Input:
5 2
1 2 3 4 5
Output:
4 5 1 2 3
Rotating right by 2 moves the last two values, 4 and 5, to the front.
Idea: reduce k to k mod n first; then the new array is the last k values followed by the first n - k values.
import sys
data = sys.stdin.read().split()
n, k = int(data[0]), int(data[1])
a = data[2:2 + n]
k %= n
print(" ".join(a[n - k:] + a[:n - k]))
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
long long k;
cin >> n >> k;
vector<string> a(n);
for (auto &x : a) cin >> x;
k %= n;
for (int i = 0; i < n; i++) {
if (i) cout << " ";
cout << a[(i - k + n) % n];
}
cout << endl;
return 0;
}
Time complexity: O(n) time, O(n) extra space.
Problem 5: Balanced brackets with three types
A string contains only the characters ( ) [ ] { }. Print YES if every bracket is closed by the same type in the right order, otherwise NO.
Input format: one non-empty line.
Output format: YES or NO.
Worked example:
Input:
([]{})
Output:
YES
Each opener is closed by its own type in nested order, so the string is balanced. The string ([)] would be NO because ] arrives while ( is on top.
Idea: push openers on a stack; on a closer the top must be its partner. At the end the stack must be empty.
s = input().strip()
pair = {')': '(', ']': '[', '}': '{'}
stack = []
ok = True
for ch in s:
if ch in '([{':
stack.append(ch)
else:
if not stack or stack[-1] != pair[ch]:
ok = False
break
stack.pop()
print("YES" if ok and not stack else "NO")
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
string st;
bool ok = true;
for (char ch : s) {
if (ch == '(' || ch == '[' || ch == '{') st.push_back(ch);
else {
char need = ch == ')' ? '(' : (ch == ']' ? '[' : '{');
if (st.empty() || st.back() != need) { ok = false; break; }
st.pop_back();
}
}
cout << ((ok && st.empty()) ? "YES" : "NO") << endl;
return 0;
}
Time complexity: O(n) time, O(n) extra space.
Problem 6: Run-length encode a string
Compress a lowercase string by writing each character followed by the length of its block, including blocks of length 1.
Input format: one non-empty line.
Output format: the encoded string.
Worked example:
Input:
aaabcc
Output:
a3b1c2
The blocks are aaa, b and cc, which become a3, b1 and c2.
Idea: use two indices: i marks the block start, j runs to the block end, then write the character and j - i.
s = input().strip()
out = []
i = 0
while i < len(s):
j = i
while j < len(s) and s[j] == s[i]:
j += 1
out.append(s[i] + str(j - i))
i = j
print("".join(out))
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
string out;
size_t i = 0;
while (i < s.size()) {
size_t j = i;
while (j < s.size() && s[j] == s[i]) j++;
out += s[i];
out += to_string(j - i);
i = j;
}
cout << out << endl;
return 0;
}
Time complexity: O(n) time, O(n) for the output.
Problem 7: Count anagram groups
Given n lowercase words, two words are in the same group if one is a rearrangement of the other. Print the number of groups.
Input format: first line n, second line n words separated by spaces.
Output format: one integer.
Worked example:
Input:
4
listen silent enlist google
Output:
2
listen, silent and enlist use the same letters, and google stands alone, so there are 2 groups.
Idea: sorting the letters of a word gives a signature that is identical for anagrams; count the distinct signatures in a set.
import sys
data = sys.stdin.read().split()
n = int(data[0])
words = data[1:1 + n]
groups = {"".join(sorted(w)) for w in words}
print(len(groups))
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
set<string> groups;
for (int i = 0; i < n; i++) {
string w;
cin >> w;
sort(w.begin(), w.end());
groups.insert(w);
}
cout << groups.size() << endl;
return 0;
}
Time complexity: O(S log L) time for S total characters when the longest word has L letters, O(S) extra space.
Problem 8: Best window of fixed size
Find the largest sum of k consecutive values in an array (1 <= k <= n).
Input format: first line n and k, second line n integers.
Output format: one integer.
Worked example:
Input:
6 3
2 1 5 1 3 2
Output:
9
The windows sum to 8, 7, 9 and 6, in that order, so the best is 9 (the window 5, 1, 3).
Idea: compute the first window once, then slide: add the value that enters, subtract the value that leaves.
import sys
data = sys.stdin.read().split()
n, k = int(data[0]), int(data[1])
a = list(map(int, data[2:2 + n]))
window = sum(a[:k])
best = window
for i in range(k, n):
window += a[i] - a[i - k]
best = max(best, window)
print(best)
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<long long> a(n);
for (auto &x : a) cin >> x;
long long window = 0;
for (int i = 0; i < k; i++) window += a[i];
long long best = window;
for (int i = k; i < n; i++) {
window += a[i] - a[i - k];
best = max(best, window);
}
cout << best << endl;
return 0;
}
Time complexity: O(n) time, O(1) extra space.
How these were checked
Each of the eight Python programs and eight C++ programs was run on hand-checked cases (four to six per problem, including edge cases such as a single element and all-equal values) and on 60 random inputs per problem, with the output compared against a deliberately slow brute-force checker. Every run matched. The C++ files were compiled with g++ using the C++17 standard. The test machine had no Java compiler, so no Java code appears on this page.
How to practise this set
Do not read the solution first. Set a timer for 25 minutes per problem, write your own version, and only then compare. Run your code on three inputs you invent: the smallest legal input, an input where every value is equal, and one large enough that a nested loop would be slow. Say your approach out loud while you do it, because the one public statement LTM makes is about explaining your approach.
WHAT PAPERSADDA THINKS
The uncomfortable truth is that nobody outside LTM can tell you exactly what your coding section looks like, and pages that give you a confident count of questions are guessing from a handful of candidate posts. We would rather give you a skill that survives either answer. If you can solve these eight cleanly in two languages and explain each in a minute, an easy-to-medium fresher coding block is not your bottleneck; communication and project depth will be. Spend the saved anxiety on those.
One personal bias: learn C++ or Python, not both at the same depth. Pick the language you read fastest, and use the other only to double-check your logic.
Related Resources
- LTIMindtree recruitment process 2026
- LTIMindtree placement papers 2026
- LTIMindtree syllabus 2026
- LTIMindtree interview questions 2026
- LTIMindtree interview process 2026
- LTIMindtree eligibility criteria 2026
Frequently Asked Questions
Does LTIMindtree (LTM) publish its fresher coding round pattern?
The ltm.com and careers.ltm.com pages PapersAdda read on 31 October 2026 do not describe the fresher online coding section. LTM's own recruitment guide describes interview stages in general terms. Number of problems, time and languages come only from candidate-reported sources, so confirm them in your own drive mail.
Is there a coding section in the LTIMindtree fresher test?
Candidate sources disagree. DesignGurus says some drives include coding with two to four programs, while PlacementPreparation.io says most recent drives no longer include coding questions. Prepare for coding and treat your drive instructions as final.
Which languages can I use?
DesignGurus lists C, C++, Java and Python as the languages candidates report. LTM does not publish a list, so check the language menu on your test screen. The practice solutions here are in Python and C++.
Were these practice problems asked in the real LTIMindtree test?
No. All eight were written by PapersAdda for practice, in the easy to medium band that candidate sources describe. None is, or claims to be, a real test question.
Are the solutions on this page tested?
Yes. Every Python and C++ solution was run on hand-checked cases and on 60 random cases compared against a slow brute-force checker, and all runs matched. Test again on your own machine, because your platform may read input in a different format.
Does LTM charge any fee for interviews or a job?
LTM's careers site says neither LTM nor its authorized recruitment agencies or partners charge any candidate registration fee or any other fees for appearing for an interview or securing employment. Treat any message asking you to pay as fraud.
Sources and review notesreviewed 6 Nov 2026
Official notices, candidate reports, offer documents, and editorial practice questions carry different confidence levels. The visible source list lets you inspect the evidence instead of relying on a blanket verification badge.
topic cluster
More resources in Company Placement Papers
Use the category hub to browse similar questions, exam patterns, salary guides, and preparation resources related to this topic.
Start with the pillar guide: LTIMindtree Interview Process 2026: Round-by-Round Guide - the complete, source-anchored reference for this cluster.
company hub
Explore all LTIMindtree resources
Open the LTIMindtree hub to jump between placement papers, interview questions, salary guides, and related pages in one place.
paid contributor programme
Sat LTIMindtree this year? Share your story, earn ₹500.
First-person experience reports help future candidates prep smarter. We pay verified contributors ₹500 via UPI per accepted story with byline.
Submit your story →ready to practice?
Take a free timed mock test
Put what you learned into practice. Our mock tests match the 2026 pattern with timer, navigator, reveal, and score breakdown. No signup.