All practice tasks

Coding (Algo)

Remove an Entry from the End

Arrays · Easy

An export editor receives values already materialized in an array. The user identifies one entry by its one-based position from the end. The editor must return a new array without that entry and leave the original export untouched.

Return the values after removing exactly the nth entry from the end while preserving the order of the others.

Input

Call

  • Implement solve(input) and return the result. The provided adapter handles JSON input and output.

Input shape

A JSON object { "values": number[], "n": number }.

Fields

  • values is a non-empty integer array. n is a one-based distance from the last entry: n=1 removes the last entry.

Output

Return value

  • Return a new array of length values.length-1.
  • Remove by index, not by value; duplicates at other indexes remain.
  • Do not change the input array. A one-entry input returns [].

Constraints

  • 1 <= values.length <= 100000; 1 <= n <= values.length.
  • Values are integers in [-1000000000,1000000000].

Examples

Example 1

{
  "n": 2,
  "values": [
    1,
    2,
    3,
    4
  ]
}

Returns

[
  1,
  2,
  4
]

Remove index 2.

Example 2

{
  "n": 1,
  "values": [
    5,
    5,
    5
  ]
}

Returns

[
  5,
  5
]

Only the last occurrence is removed.

Required complexity

O(length) time to construct the output; O(1) working space excluding the returned array

What this task practices

Remove an Entry from the End is a coding (algo) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as easy difficulty. It focuses on Technical Reasoning, Testing, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.