LTIMindtree Coding Round Questions with Solutions
Last updated 2026-11-19
This page practises the medium-level problems that IT services and mixed-product tests commonly use, with ten worked solutions in Python and Java. LTIMindtree has not published its test content, so the set is general practice rather than a claim about a specific paper.
Use it with LTIMindtree interview questions and how to crack the DSA coding round.
| Level | Medium, with two hard items |
|---|---|
| Languages | Python and Java shown |
| Topics | Two pointers, DP, graphs, stacks, design |
What to expect from an LTIMindtree-style coding test
LTIMindtree does not publish its test content, and we have no sourced description of its fresher coding round, so these ten problems are practice for medium-level IT services and product-adjacent tests in general: two pointers, binary search variants, dynamic programming, graph ordering, design-style classes and recursion. Treat them as practice in the style of those topics, not as questions from any particular paper. The mix also reflects what interviewers use to probe a candidate who lists data structures on a resume.
How to practise them
- Write the brute force first and state its complexity.
- Name the pattern (two pointers, monotonic stack, DP, topological sort) before coding.
- For class-design problems such as LRU cache and MinStack, write the API first, then the internals.
- Re-run examples with duplicates and empty input.
LTIMindtree Coding Round Questions with Solutions: questions with worked answers
1 Three Sum: unique triplets that add to zero
mediumSort the array. For each index i, run two pointers on the rest looking for a pair summing to -a[i]. Skip duplicate values at i and at the pointers to keep triplets unique. Complexity: O(n squared) time, O(1) extra space. Common mistakes: not skipping duplicates, which repeats triplets, and using a set of tuples when sorting plus skipping is cleaner.
pythondef three_sum(a): a.sort(); out = [] for i in range(len(a) - 2): if i and a[i] == a[i - 1]: continue l, r = i + 1, len(a) - 1 while l < r: s = a[i] + a[l] + a[r] if s < 0: l += 1 elif s > 0: r -= 1 else: out.append([a[i], a[l], a[r]]); l += 1; r -= 1 while l < r and a[l] == a[l - 1]: l += 1 return out print(three_sum([-1, 0, 1, 2, -1, -4])) # [[-1, -1, 2], [-1, 0, 1]]javaimport java.util.*; class Solution { static List<List<Integer>> threeSum(int[] a) { Arrays.sort(a); List<List<Integer>> out = new ArrayList<>(); for (int i = 0; i < a.length - 2; i++) { if (i > 0 && a[i] == a[i - 1]) continue; int l = i + 1, r = a.length - 1; while (l < r) { int s = a[i] + a[l] + a[r]; if (s < 0) l++; else if (s > 0) r--; else { out.add(Arrays.asList(a[i], a[l], a[r])); l++; r--; while (l < r && a[l] == a[l - 1]) l++; } } } return out; } }2 Search in a rotated sorted array
mediumBinary search where at least one half is always sorted. Check which half is sorted, test whether the target lies in it, and discard the other half. Complexity: O(log n) time, O(1) space. Common mistakes: comparing with the wrong boundary (use <= for the sorted-half check) and assuming duplicates, which this version does not support.
pythondef search(a, t): lo, hi = 0, len(a) - 1 while lo <= hi: mid = (lo + hi) // 2 if a[mid] == t: return mid if a[lo] <= a[mid]: if a[lo] <= t < a[mid]: hi = mid - 1 else: lo = mid + 1 else: if a[mid] < t <= a[hi]: lo = mid + 1 else: hi = mid - 1 return -1 print(search([4, 5, 6, 7, 0, 1, 2], 0)) # 4javaclass Solution { static int search(int[] a, int t) { int lo = 0, hi = a.length - 1; while (lo <= hi) { int mid = lo + (hi - lo) / 2; if (a[mid] == t) return mid; if (a[lo] <= a[mid]) { if (a[lo] <= t && t < a[mid]) hi = mid - 1; else lo = mid + 1; } else { if (a[mid] < t && t <= a[hi]) lo = mid + 1; else hi = mid - 1; } } return -1; } }3 Word break
mediumdp[i] is true if the first i characters can be segmented. For each i, check any j < i where dp[j] is true and s[j:i] is in the dictionary. Use a set for the dictionary. Complexity: O(n squared) substring checks, O(n) space. Common mistakes: using greedy longest-word matching, which fails on cases such as 'cars' with words car, ca, rs, and forgetting dp[0] = true.
pythondef word_break(s, words): w = set(words) dp = [True] + [False] * len(s) for i in range(1, len(s) + 1): dp[i] = any(dp[j] and s[j:i] in w for j in range(i)) return dp[-1] print(word_break("leetcode", ["leet", "code"]), word_break("catsandog", ["cats", "dog", "sand", "and", "cat"])) # True Falsejavaimport java.util.*; class Solution { static boolean wordBreak(String s, List<String> words) { Set<String> w = new HashSet<>(words); boolean[] dp = new boolean[s.length() + 1]; dp[0] = true; for (int i = 1; i <= s.length(); i++) for (int j = 0; j < i; j++) if (dp[j] && w.contains(s.substring(j, i))) { dp[i] = true; break; } return dp[s.length()]; } }4 LRU cache with O(1) get and put
hardCombine a hash map with a structure that tracks recency. Python's OrderedDict and Java's LinkedHashMap with access order do this directly; move a key to the end on every access and evict from the front when over capacity. Complexity: O(1) average per operation, O(capacity) space. Common mistakes: forgetting to refresh recency on get and on updates to existing keys, and evicting before checking whether the key already exists.
pythonfrom collections import OrderedDict class LRU: def __init__(self, cap): self.cap, self.d = cap, OrderedDict() def get(self, k): if k not in self.d: return -1 self.d.move_to_end(k); return self.d[k] def put(self, k, v): self.d[k] = v; self.d.move_to_end(k) if len(self.d) > self.cap: self.d.popitem(last=False) c = LRU(2); c.put(1, 1); c.put(2, 2); c.get(1); c.put(3, 3) print(c.get(2), c.get(1)) # -1 1javaimport java.util.*; class LRU extends LinkedHashMap<Integer, Integer> { private final int cap; LRU(int cap) { super(16, 0.75f, true); this.cap = cap; } int getOrMinus(int k) { return getOrDefault(k, -1); } @Override protected boolean removeEldestEntry(Map.Entry<Integer, Integer> e) { return size() > cap; } }5 Longest common subsequence
mediumdp[i][j] is the LCS length of the first i characters of a and first j of b. If the characters match, add 1 to dp[i-1][j-1], otherwise take the larger of dp[i-1][j] and dp[i][j-1]. Complexity: O(m * n) time and space (O(min(m, n)) with rolling rows). Common mistakes: confusing subsequence with substring (which needs a reset to 0) and off-by-one in the table indexes.
pythondef lcs(a, b): dp = [[0] * (len(b) + 1) for _ in range(len(a) + 1)] for i in range(1, len(a) + 1): for j in range(1, len(b) + 1): if a[i - 1] == b[j - 1]: dp[i][j] = dp[i - 1][j - 1] + 1 else: dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) return dp[-1][-1] print(lcs("abcde", "ace")) # 3javaclass Solution { static int lcs(String a, String b) { int[][] dp = new int[a.length() + 1][b.length() + 1]; for (int i = 1; i <= a.length(); i++) for (int j = 1; j <= b.length(); j++) dp[i][j] = a.charAt(i - 1) == b.charAt(j - 1) ? dp[i - 1][j - 1] + 1 : Math.max(dp[i - 1][j], dp[i][j - 1]); return dp[a.length()][b.length()]; } }6 Course schedule: can all courses be finished?
hardModel prerequisites as a directed graph and run Kahn's topological sort: repeatedly remove nodes with in-degree zero. If every node is removed there is no cycle and the answer is yes. Complexity: O(V + E) time and space. Common mistakes: building edges in the wrong direction and not counting processed nodes, which hides cycles.
pythonfrom collections import deque def can_finish(n, prereq): g, indeg = [[] for _ in range(n)], [0] * n for a, b in prereq: g[b].append(a); indeg[a] += 1 q = deque(i for i in range(n) if indeg[i] == 0) done = 0 while q: u = q.popleft(); done += 1 for v in g[u]: indeg[v] -= 1 if indeg[v] == 0: q.append(v) return done == n print(can_finish(2, [[1, 0]]), can_finish(2, [[1, 0], [0, 1]])) # True Falsejavaimport java.util.*; class Solution { static boolean canFinish(int n, int[][] prereq) { List<List<Integer>> g = new ArrayList<>(); for (int i = 0; i < n; i++) g.add(new ArrayList<>()); int[] indeg = new int[n]; for (int[] p : prereq) { g.get(p[1]).add(p[0]); indeg[p[0]]++; } Deque<Integer> q = new ArrayDeque<>(); for (int i = 0; i < n; i++) if (indeg[i] == 0) q.add(i); int done = 0; while (!q.isEmpty()) { int u = q.poll(); done++; for (int v : g.get(u)) if (--indeg[v] == 0) q.add(v); } return done == n; } }7 Lowest common ancestor of a binary search tree
mediumUse the BST property: if both values are smaller than the node, go left; if both are larger, go right; otherwise the current node is the split point and the answer. Complexity: O(h) time, O(1) space iteratively. Common mistakes: using the generic binary-tree algorithm (slower) and forgetting that a node can be its own ancestor.
pythonclass T: def __init__(self, v, l=None, r=None): self.v, self.l, self.r = v, l, r def lca(root, p, q): while root: if p < root.v and q < root.v: root = root.l elif p > root.v and q > root.v: root = root.r else: return root.v tree = T(6, T(2, T(0), T(4)), T(8)) print(lca(tree, 2, 8), lca(tree, 0, 4)) # 6 2javaclass Solution { static class T { int v; T l, r; T(int v) { this.v = v; } } static int lca(T root, int p, int q) { while (root != null) { if (p < root.v && q < root.v) root = root.l; else if (p > root.v && q > root.v) root = root.r; else return root.v; } return -1; } }8 Min stack with O(1) minimum
mediumStore each value together with the minimum so far, in a single stack of pairs (or a second stack). The minimum is the second element of the top pair, and pop restores the previous minimum automatically. Complexity: O(1) per operation, O(n) space. Common mistakes: tracking one global minimum variable, which becomes wrong after the minimum is popped.
pythonclass MinStack: def __init__(self): self.s = [] def push(self, x): self.s.append((x, min(x, self.s[-1][1]) if self.s else x)) def pop(self): return self.s.pop()[0] def top(self): return self.s[-1][0] def get_min(self): return self.s[-1][1] m = MinStack(); m.push(3); m.push(1); m.push(2) print(m.get_min()); m.pop(); m.pop(); print(m.get_min()) # 1 then 3javaimport java.util.*; class MinStack { private final Deque<int[]> s = new ArrayDeque<>(); void push(int x) { s.push(new int[]{x, s.isEmpty() ? x : Math.min(x, s.peek()[1])}); } int pop() { return s.pop()[0]; } int top() { return s.peek()[0]; } int getMin() { return s.peek()[1]; } }9 Generate all valid parentheses of n pairs
mediumBacktrack building the string: add an opening bracket while fewer than n have been used, and add a closing bracket only while closes are fewer than opens. Every string reaching length 2n is valid. Complexity: O(4^n / sqrt(n)) output size (Catalan number), O(n) recursion depth. Common mistakes: trying all 2^(2n) strings and filtering, and allowing a close bracket when none is open.
pythondef gen(n): out = [] def go(s, o, c): if len(s) == 2 * n: out.append(s); return if o < n: go(s + '(', o + 1, c) if c < o: go(s + ')', o, c + 1) go('', 0, 0) return out print(gen(3))javaimport java.util.*; class Solution { static List<String> gen(int n) { List<String> out = new ArrayList<>(); go(new StringBuilder(), 0, 0, n, out); return out; } static void go(StringBuilder s, int o, int c, int n, List<String> out) { if (s.length() == 2 * n) { out.add(s.toString()); return; } if (o < n) { s.append('('); go(s, o + 1, c, n, out); s.deleteCharAt(s.length() - 1); } if (c < o) { s.append(')'); go(s, o, c + 1, n, out); s.deleteCharAt(s.length() - 1); } } }10 Daily temperatures: days until a warmer day
mediumMonotonic stack of indices with decreasing temperatures. When the current temperature is higher than the stack top's, pop and set the answer to the index difference. Complexity: O(n) time, O(n) space. Common mistakes: a nested loop (O(n squared)) and storing temperatures instead of indices.
pythondef daily(t): res, st = [0] * len(t), [] for i, x in enumerate(t): while st and t[st[-1]] < x: j = st.pop(); res[j] = i - j st.append(i) return res print(daily([73, 74, 75, 71, 69, 72, 76, 73])) # [1, 1, 4, 2, 1, 1, 0, 0]javaimport java.util.*; class Solution { static int[] daily(int[] t) { int[] res = new int[t.length]; Deque<Integer> st = new ArrayDeque<>(); for (int i = 0; i < t.length; i++) { while (!st.isEmpty() && t[st.peek()] < t[i]) { int j = st.pop(); res[j] = i - j; } st.push(i); } return res; } }
Frequently asked questions
What is the LTIMindtree coding test format?
It is not published here. Check your invitation for platform, duration and languages.
Do I need dynamic programming?
It appears in many medium tests, so know the basics: coin change, LCS, word break.
Is Java or Python better?
Either. Python is shorter; Java suits roles that list it.
Where do I find openings?
Use the official careers site at ltimindtree.com/careers.
Sources
Related guides
More in Company Interview Questions
- LTIMindtree Interview Questions for Freshers
- LTTS coding round questions
- MakeMyTrip Coding Round Questions
- MakeMyTrip Interview Questions with Answers
- Mastercard coding round questions with solutions
- Mastercard interview questions with answers (software engineer)
- Media.net Coding Round Questions With Solutions
- Media.net Interview Questions and Answers
- Meesho Coding Round Questions with Solutions
- Meesho Interview Questions and Answers
- Meta Coding Round Questions with Solutions in Python and Java
- Meta Interview Questions and Answers for SDE Roles