Dell Technologies Coding Questions: Three Patterns with Solved Examples
Learn to recognise three coding patterns and explain why they work. Trace original practice problems, test the mistakes that break them, and apply the methods to a fresh input.
KnowledgeGate Team
Exam prep & CS education

Company labels alone do not teach pattern recognition. A hash map, a sliding window and sort-and-scan each answer a different requirement in these original practice problems for Dell Technologies interview preparation. They are not verified previously asked Dell questions or evidence of patterns Dell favours, so use your actual role and invitation to decide which language and topics to practise.
1. Read the requirement before choosing the pattern
An invariant is a fact the algorithm keeps true after each step. Before choosing an algorithm, clarify the required output: indices, a length, or a collection of intervals.
Requirement | Useful pattern |
|---|---|
Two distinct positions with a target sum | Seen-value hash map |
Longest contiguous substring without repetition | Sliding window |
Combine overlapping closed intervals | Sort and scan |
We use zero-based indices throughout. A substring is contiguous; a subsequence can skip characters. Our intervals are closed, so touching endpoints merge. These details decide whether an answer is correct.
Python 3 keeps the examples readable; the language choice here does not establish what an assessment permits. If arrays, strings or loops still slow you down, revisit language fundamentals through Coding & Skills before practising these methods.
2. Hash-map example: return two distinct indices with a target sum
Given nums = [4, 1, 7, 4] and target = 8, return two distinct indices, or None if no pair exists. Checking every pair takes O(n²) time and O(1) extra space. Instead, remember values already visited.
def two_sum(nums, target):
seen = {}
for i, x in enumerate(nums):
need = target - x
if need in seen:
return (seen[need], i)
seen[x] = i
return NoneBefore each lookup, every stored index is earlier than i. This invariant guarantees distinct positions.
At index 0, need = 8 - 4 = 4. The map is empty, so store {4: 0}. At index 1, need = 8 - 1 = 7; it is absent, so store {4: 0, 1: 1}. At index 2, need = 8 - 7 = 1 matches index 1. Return (1, 2) because 1 + 7 = 8.
![Diagram of a two-sum scan for [4, 1, 7, 4] with target 8, showing two misses before a map hit returns indices (1, 2).](https://cdn.knowledgegate.ai/blog-assets/blog_asset_1790082663860_rru69n.jpg)
(0, 3) is also valid, but this scan returns the first pair it discovers. Lookup before insertion prevents using the current element twice.
Tests with target 8: [4] returns None; [4,4] and [-3,11] both return (0,1). Expected time is O(n) with average constant-time hash operations; extra space is O(n). For a Java companion, use HashMap and HashSet practice in Java.
3. Sliding-window example: longest substring without repeated characters
For s = "pwwkew", return the longest valid substring's length, not the substring itself. The answer is 3, witnessed by "wke" or "kew".
def longest_unique(s):
last = {}
left = best = 0
for right, ch in enumerate(s):
if ch in last:
left = max(left, last[ch] + 1)
last[ch] = right
# The current window contains no repeated character.
best = max(best, right - left + 1)
return bestThe maintained window contains no duplicate character. When a repeated character lies inside it, move left just beyond the previous occurrence.
right | Character | left | Window | Length calculation | best |
|---|---|---|---|---|---|
0 | p | 0 | p | 0 - 0 + 1 = 1 | 1 |
1 | w | 0 | pw | 1 - 0 + 1 = 2 | 2 |
2 | w | 2 | w | 2 - 2 + 1 = 1 | 2 |
3 | k | 2 | wk | 3 - 2 + 1 = 2 | 2 |
4 | e | 2 | wke | 4 - 2 + 1 = 3 | 3 |
5 | w | 3 | kew | 5 - 3 + 1 = 3 | 3 |

At the final w, its previous occurrence is inside the window. max(3, 2 + 1) = 3 keeps the left boundary moving forward.
The empty string returns 0, "aaaa" returns 1, and "abc" returns 3. Expected time is O(n) under average hash-map operations. Space is O(min(n, number of possible characters)). This movement rule serves the no-duplicate condition; it does not automatically solve arbitrary sum problems.
4. Sort-and-scan example: merge overlapping intervals
Merge [[8,10],[1,3],[2,6],[10,12]], assuming each start is at most its end. Sorting by start gives [[1,3],[2,6],[8,10],[10,12]].
def merge_intervals(intervals):
result = []
for start, end in sorted(intervals):
if not result or start > result[-1][1]:
result.append([start, end])
else:
result[-1][1] = max(result[-1][1], end)
return resultTrace the accumulator:
Start with
[[1,3]].Since
2 <= 3, extend the end tomax(3,6) = 6:[[1,6]].Since
8 > 6, append:[[1,6],[8,10]].Since
10 <= 10, extend tomax(10,12) = 12:[[1,6],[8,12]].
Endpoints 10 and 10 overlap because both closed intervals contain 10. A half-open interval convention would require a different rule for touching endpoints.
The result remains sorted and non-overlapping. Only its last interval can be extended by the next sorted interval, so earlier results need no further checks.
Empty input returns []. Nested [[1,10],[2,3]] returns [[1,10]]; separate [[1,2],[3,4]] remains unchanged. Sorting dominates at O(n log n) time. This implementation uses O(n) auxiliary/output storage, including the sorted copy.
5. Three traps that pass the sample but fail edge cases
Hashing: inserting first makes
[4], target 8, find its own index and incorrectly return(0,0). Check the complement before insertion. Positions must differ; values need not.Window: assigning
left = last[ch] + 1withoutmaxmoves left from 2 to 1 at the finalainabcbda. It falsely acceptsbcbdaand reports 5 instead of 4. Usemaxto preserve the no-duplicate invariant recorded in the comment.Intervals: replacing the current end with the incoming end turns
[1,10]into[1,3]when processing nested[2,3]. It loses covered points. Usemax(10,3) = 10to retain the full interval.
For every implementation, choose a test that attacks its update rule. A passing ordinary example proves little about duplicates, old occurrences or nesting.
6. How to demonstrate the method in a coding assessment
Practise a repeatable explanation: state input assumptions, give a simple baseline, explain the invariant, implement the improvement, then run an ordinary case and a counterexample. Finish with time and space complexity. The hash-map, window and interval examples support this workflow.
The earlier Publicis Sapient coding-patterns post owns the Java versions of complement lookup, sliding windows and interval merging. This Dell-focused set uses Python traces, the pwwkew boundary case and adversarial tests to make each update rule explainable.
Use Dell Technologies' official careers portal for the current vacancy, and check your role-specific invitation or recruiter instructions for allowed languages and assessment details.
Try a self-imposed 25-minute practice session: 5 minutes for requirements and the baseline, 15 for implementation, and 5 for tests and complexity. This is an editorial exercise, not Dell's assessment duration. For broader preparation habits, read the coding-round strategy guide.
7. Short version and the next practice task
Hashing remembers useful earlier values. A window maintains a valid contiguous range. Sorting intervals lets a single scan finish merging.
Now merge [[5,7],[1,2],[2,4],[6,8]]. The expected result is [[1,4],[5,8]]. Explain why endpoints 2 and 2 merge before running code, then reimplement all three methods in your preferred language.
For an optional structured next step, Coding for Placements is an available practice course. Start by solving these examples without looking at the code.
Keep learning
Persistent Systems Coding Questions: Three Patterns with Solved Examples
Recognise when to use complement lookup, a sliding window or a running best sum. Work through three Python solutions and the edge cases that expose common mistakes.
Coforge Coding Questions: Three Patterns with Solved Examples
Recognising a coding problem is only the start. Practise second distinct maximum, first non-repeating character and maximum subarray sum with complete Python functions and edge-case checks.
Publicis Sapient Coding Questions: Three Patterns with Worked Solutions
Recognising code is easier than explaining why it works. Practise three patterns through Java methods, exact traces, invariants and edge cases before your next coding assessment.
JPMorgan Chase Coding Questions: Three Patterns with Solved Examples
Know a solution but struggle when the input changes? Practise complement lookup, sliding windows and take-or-skip dynamic programming with exact traces and clear invariants.





