contentintech
Learn/Fresher SDE Preparation/Placement Mock Practice
Beginner~6 min read + exercises

Placement Mock Practice: An Original Self-Timed SDE Session

Run an original 75-minute fresher practice session with twelve explained questions, two coding tasks, and a diagnostic scoring rubric.

SDEPlacementMock PracticeDSAAptitude

Set up your own practice session

These original questions are not an employer past paper or assessment prediction. It is a self-timed reading and coding exercise: this page does not implement an interactive exam, automatic marking, or a submission system.

Use a timer, paper, and your usual editor. Allow 20 minutes for the twelve questions, 40 minutes for both coding tasks, and fifteen minutes for review. Attempt the questions before reading their answers. Work independently for this practice attempt. Follow the organiser's rules in a real assessment.

Record reasoning and coding tests. Stop when time expires and preserve incomplete work.

Twelve questions with explained answers

1. Successive percentages

A club buys equipment for ₹800, adds a 25% markup, then discounts that marked price by 10%. What is the sale price and profit percentage on cost?

Answer: The marked price is ₹1,000; the sale price is ₹900. Profit is ₹100, or 12.5% of ₹800. The percentages use different bases, so subtracting 10 from 25 gives the wrong profit.

2. Combined work

Worker A completes a job in six hours and B in three. Assuming constant independent rates, how long do they need together?

Answer: Their rates add to one-sixth plus one-third, or one-half job per hour. They need two hours. This model assumes neither worker obstructs the other; averaging completion times is inappropriate.

3. Probability without replacement

A bag contains three red and two blue tokens. What is the probability that two draws without replacement are both red?

Answer: Three-fifths times two-fourths equals three-tenths. After a red first draw, only two red tokens remain among four. Keeping the original denominator for the second draw would model replacement.

4. Queue trace

An empty FIFO queue receives A, then B. One item is removed, C is added, and another item is removed. Which item remains?

Answer: C remains. The removals take A and then B because FIFO serves the earliest queued item. Removing B first would use stack-like behavior.

5. Nested-loop cost

For each index i from zero through n minus one, an inner loop runs i times. What is the asymptotic total work?

Answer: The iterations sum to n times n minus one, divided by two. The cost is O(n squared). A changing inner-loop limit does not make the total linear.

6. HTTP status distinction

How do 401 and 403 differ?

Answer: 401 indicates missing valid authentication credentials and requires an authentication challenge. 403 indicates that the server understood the request but refuses it; valid credentials may lack sufficient access. It is not exclusively a “logged-in user” status. See RFC 9110.

7. Duplicate registration

Two concurrent requests try to register the same non-null email. Why can an application-only “email exists” check fail?

Answer: Both may check before either inserts. A database uniqueness constraint enforces the invariant, and the application handles its violation. Define normalisation separately. PostgreSQL constraints document database-enforced uniqueness.

8. Access control

An endpoint accepts a note ID and a user ID supplied by the caller. Is filtering by those values sufficient?

Answer: No. Derive the user identity from verified authentication and check access to the note. Caller-supplied ownership is untrusted. OWASP authorization guidance recommends validating permissions on every request.

9. Test selection

A function returns the second-largest distinct number. Which test challenges it more: [1, 2, 3] or [1, 3, 3]?

Answer: The second input exposes duplicate handling. The expected result is 1, while an implementation returning the penultimate sorted element produces 3. Also test fewer than two distinct values.

10. Team disagreement

Your team disagrees about adding a feature before a demo. What should your answer explain?

Answer: State the required demo outcome, compare options using evidence, describe your own action, and report the actual decision and result. Avoid inventing agreement. Amazon's official STAR advice offers one useful answer structure, not universal hiring criteria.

11. AI suggestion

An AI-generated function passes one happy-path test. What is your next step?

Answer: Review it against the contract, create independent edge-case expectations, check unfamiliar APIs, and inspect relevant security assumptions. One passing example is insufficient. GitHub's responsible-use guidance calls for human review and validation.

12. Unsupported project metric

You wrote “50% faster” on your resume but cannot reproduce the measurement. How should you prepare?

Answer: Remove or qualify the unsupported number. Re-measure with a defined workload and report the actual evidence, or describe the implemented change without a performance claim. Honest scope is easier to defend than invented precision.

Coding task A: first unique registration code

Given a list of case-sensitive strings, return the earliest string appearing exactly once, or None. Do not modify the input. For ["a", "b", "a", "c"], return "b". Empty input and ["a", "a"] return None.

python
def first_unique(codes):
    counts = {}
    for code in codes:
        counts[code] = counts.get(code, 0) + 1
    for code in codes:
        if counts[code] == 1:
            return code
    return None

The first pass computes frequency; the second preserves input order. Returning during the first pass fails because a later occurrence can invalidate uniqueness. With bounded-length strings and expected constant-time dictionary operations, time is O(n) and auxiliary space O(u), where u is the distinct count. String hashing adds cost for long strings.

Coding task B: peak active sessions

Each pair contains integer start and end times with start strictly before end. Intervals are half-open: a session ending at time t does not overlap one starting at t. Return maximum simultaneous sessions; empty input returns zero. For [(1, 4), (2, 3), (4, 6)], return two.

python
def peak_sessions(intervals):
    events = []
    for start, end in intervals:
        if start >= end:
            raise ValueError("invalid interval")
        events.extend([(start, 1), (end, -1)])
    active = peak = 0
    for time, change in sorted(events):
        active += change
        peak = max(peak, active)
    return peak

Sorting tuples processes minus-one endings before plus-one starts at equal times, matching the contract. Otherwise adjacent sessions could falsely overlap. Time is O(n log n), space O(n). Test touching intervals, identical intervals, nested intervals, empty input, and invalid bounds.

Score and choose your next repair

Give each question one point for the answer and one for its explanation: 24 total. Give each coding task eight points: three for correct behavior, two for edge tests, two for reasoning and complexity, and one for clarity. Total: 40.

A practice score of 32 or more suggests trying a harder variant; 24–31 suggests targeted repairs; below 24 suggests returning to fundamentals. These are diagnostic thresholds, not employer cutoffs. Treat incorrect access control as a required repair regardless of total score.

Use Testing, DSA, and aptitude for follow-up exercises. Research roles in Companies and correct unsupported claims in the resume builder. Retry your two weakest skills after a gap with changed inputs.

Continue on the SDE preparation track

Build on this lesson with Project interviews, Behavioural communication, Responsible AI coding, Revision readiness.

Primary references appear beside factual answers. Questions, coding tasks, timing, and scoring are original teaching material; no employer endorsement or assessment implementation is claimed.

Course navigation

Course overview · Previous lesson · Next lesson

Section navigation