Media.net Coding Round Questions With Solutions
Last updated 2026-11-19
Media.net coding rounds are commonly reported to be demanding, with medium to hard algorithmic problems and an expectation that you can explain complexity and edge cases clearly. The eleven practice problems below cover the techniques most often useful: two pointers, dynamic programming, heaps, graphs and sliding windows.
They are practice problems, not real papers. For interview and design questions see Media.net interview questions, and for general preparation read how to crack a DSA coding round.
Approach
Start by restating the problem and giving a brute force with its complexity. Then identify the bottleneck: repeated work suggests memoisation, sorted structure suggests two pointers or binary search, and "best so far" suggests a heap. Write code, then trace a small example by hand.
Hiring status
We hold no sourced hiring dates, numbers or format details for Media.net, so none are stated. Check the company's own careers site for current roles. For test strategy see how to crack the online assessment.
Media.net Coding Round Questions With Solutions: questions with worked answers
1 Trapping rain water.
hardUse two pointers with the running maximum height on each side. Move the pointer on the lower side; the water above that bar is the side's maximum minus its height. O(n) time, O(1) space. Mistake: using the global maximum for both sides instead of the smaller of the two side maxima.
pythondef trap(h): l, r = 0, len(h) - 1 lm = rm = water = 0 while l < r: if h[l] < h[r]: lm = max(lm, h[l]) water += lm - h[l] l += 1 else: rm = max(rm, h[r]) water += rm - h[r] r -= 1 return water2 Median of two sorted arrays in O(log(min(m, n))).
hardBinary search a partition of the shorter array so that the left halves of both arrays together hold half the elements and every left element is at most every right element. The median comes from the boundary elements. Mistake: not padding with infinity when a partition lies at an array edge.
pythondef median(a, b): if len(a) > len(b): a, b = b, a m, n = len(a), len(b) lo, hi, half = 0, m, (m + n + 1) // 2 inf = float('inf') while lo <= hi: i = (lo + hi) // 2 j = half - i al = a[i-1] if i else -inf ar = a[i] if i < m else inf bl = b[j-1] if j else -inf br = b[j] if j < n else inf if al <= br and bl <= ar: if (m + n) % 2: return max(al, bl) return (max(al, bl) + min(ar, br)) / 2 if al > br: hi = i - 1 else: lo = i + 13 Word break: can a string be segmented into dictionary words?
mediumdp[i] is true if the prefix of length i can be segmented. For each i, check each j less than i with dp[j] true and s[j:i] in the set. O(n squared) with O(1) set lookups, ignoring slicing cost. Limit j to the maximum word length to speed it up.
pythondef word_break(s, words): ws, mx = set(words), max(map(len, words)) dp = [True] + [False] * len(s) for i in range(1, len(s) + 1): for j in range(max(0, i - mx), i): if dp[j] and s[j:i] in ws: dp[i] = True break return dp[-1]4 Longest valid parentheses substring.
hardUse a stack of indices, starting with -1 as a base. On "(" push the index; on ")" pop, and if the stack becomes empty push the current index as the new base, otherwise the length is the index minus the new top. O(n) time and space. Mistake: forgetting the base marker, which makes the length calculation fail for strings starting with a valid pair.
pythondef longest_valid(s): st, best = [-1], 0 for i, ch in enumerate(s): if ch == '(': st.append(i) else: st.pop() if not st: st.append(i) else: best = max(best, i - st[-1]) return best5 Minimum window substring.
hardCount the characters needed from t. Expand the right pointer, decrementing needs; when every need is met, shrink from the left while it stays valid, recording the shortest window. O(n + m). Mistake: updating the missing-character counter on every character instead of only when a needed character's count goes from positive to zero or back.
pythonfrom collections import Counter def min_window(s, t): need, missing = Counter(t), len(t) best, left = (0, float('inf')), 0 for right, ch in enumerate(s): if need[ch] > 0: missing -= 1 need[ch] -= 1 if missing == 0: while need[s[left]] < 0: need[s[left]] += 1 left += 1 if right - left < best[1] - best[0]: best = (left, right) need[s[left]] += 1 missing += 1 left += 1 return '' if best[1] == float('inf') else s[best[0]:best[1] + 1]6 Maximum profit in job scheduling (weighted interval scheduling).
hardSort jobs by end time. Let dp[i] be the best profit using the first i jobs. For job i, either skip it, or take it plus dp at the last job ending at or before its start, found by binary search. O(n log n). Mistake: using a greedy by profit or by earliest end alone.
pythonfrom bisect import bisect_right def job_scheduling(start, end, profit): jobs = sorted(zip(end, start, profit)) ends = [j[0] for j in jobs] dp = [0] * (len(jobs) + 1) for i, (e, s, p) in enumerate(jobs, 1): k = bisect_right(ends, s, 0, i - 1) dp[i] = max(dp[i-1], dp[k] + p) return dp[-1]7 Alien dictionary: derive letter order from sorted words.
hardCompare adjacent words to find the first differing letter, which gives an edge a before b. Then topologically sort the letters. If a longer word precedes its own prefix, or the sort has a cycle, the input is invalid. O(total characters + alphabet). Mistake: forgetting letters that appear in no edge.
pythonfrom collections import deque def alien_order(words): adj = {c: set() for w in words for c in w} indeg = {c: 0 for c in adj} for a, b in zip(words, words[1:]): if len(a) > len(b) and a.startswith(b): return '' for x, y in zip(a, b): if x != y: if y not in adj[x]: adj[x].add(y) indeg[y] += 1 break q = deque(c for c in indeg if indeg[c] == 0) out = [] while q: c = q.popleft() out.append(c) for n in adj[c]: indeg[n] -= 1 if indeg[n] == 0: q.append(n) return ''.join(out) if len(out) == len(indeg) else ''8 Count the numbers smaller than each element to its right.
hardProcess from right to left with a Fenwick tree over compressed values. For each number, query the count of values strictly smaller than it already inserted, then insert it. O(n log n). Mistake: using a nested loop, which is O(n squared) and times out on large input.
pythondef count_smaller(a): ranks = {v: i + 1 for i, v in enumerate(sorted(set(a)))} tree = [0] * (len(ranks) + 2) def add(i): while i < len(tree): tree[i] += 1 i += i & -i def query(i): s = 0 while i > 0: s += tree[i] i -= i & -i return s out = [] for x in reversed(a): out.append(query(ranks[x] - 1)) add(ranks[x]) return out[::-1]9 N-Queens: count the placements.
hardBacktrack row by row, tracking used columns and both diagonals (row minus col and row plus col) in sets or bitmasks. O(n!) in the worst case, pruned heavily. Mistake: using the same diagonal key for both diagonal directions.
pythondef n_queens(n): cols, d1, d2 = set(), set(), set() def go(r): if r == n: return 1 total = 0 for c in range(n): if c in cols or r - c in d1 or r + c in d2: continue cols.add(c); d1.add(r - c); d2.add(r + c) total += go(r + 1) cols.remove(c); d1.remove(r - c); d2.remove(r + c) return total return go(0)10 Top K frequent words, ties broken alphabetically.
mediumCount with a dictionary, then take the k best by sorting on (negative count, word), or use a heap of size k with a custom order. A sort is O(n log n); a heap is O(n log k). Mistake: sorting only by count, which leaves ties in arbitrary order.
pythonfrom collections import Counter def top_k_words(words, k): c = Counter(words) return sorted(c, key=lambda w: (-c[w], w))[:k]javastatic java.util.List<String> topK(String[] words, int k) { java.util.Map<String,Integer> c = new java.util.HashMap<>(); for (String w : words) c.merge(w, 1, Integer::sum); java.util.List<String> keys = new java.util.ArrayList<>(c.keySet()); keys.sort((a, b) -> c.get(a).equals(c.get(b)) ? a.compareTo(b) : c.get(b) - c.get(a)); return keys.subList(0, Math.min(k, keys.size())); }
Frequently asked questions
How hard is the Media.net coding round?
Commonly reported as medium to hard. Expect to explain complexity and handle edge cases, not just pass samples.
Which topics come up most?
Dynamic programming, graphs, heaps, strings and array problems with sliding windows or two pointers.
Should I memorise solutions?
No. Learn the pattern behind each, since interviewers vary the constraints.
Is there a coding test before interviews?
Candidate accounts commonly mention one. Your invitation will state the format.
Related guides
More in Company Interview Questions
- 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
- Micron Coding Round Questions with Solutions
- Micron Interview Questions and Answers for India Software and Firmware Roles
- Microsoft Coding Round Questions with Solutions in Python and Java
- Microsoft Interview Questions and Answers for SDE Roles
- Morgan Stanley coding round questions with solutions
- Morgan Stanley interview questions with answers (technology analyst)
- Mphasis Coding Round Questions with Solutions