The interview problem

Practice prompt

Solve a quadratic-plus-L1 subproblem and explain why coefficients can become exactly zero.

Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.

1. Scope and worked approach

Minimize 0.5(x−z)²+λ|x|. On x>0 the stationary point is z−λ; on x<0 it is z+λ. Combine sign consistency with the subgradient condition at zero to obtain sign(z)max(|z|−λ,0).

2. Trace the design or derivation

Smooth-gradient proposal
  → L1 proximal problem
  → sign cases
  → sparse update

For objective f(x)+λ||x||1 with step η, apply threshold ηλ after the smooth-gradient step x−η∇f(x). A penalty parameter copied from a different learning rate changes the update unless this scaling is preserved.

3. Calculate the example

For z=[3,−1,0.4] and λ=1, the solution is [2,0,0]. This is a proximal step, not merely subtracting one from every coordinate.

4. Failure cases and trade-offs

A gradient step on the smooth term and a proximal step on the penalty have different roles. Feature scaling changes the practical meaning of a shared λ.

5. Validation, follow-ups and self-review

Check positive, negative and threshold-equality cases. Follow-up: how does the step size rescale λ? Self-review: justify the zero region using a subgradient.

Sources and related practice

Technical reference: web.stanford.edu — L1 proximal operator and proximal-gradient scaling.

Source publication/update: 2014. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.

Continue with Connect regularization with probabilistic priors; Use KKT conditions to identify an active constraint.

Continue your preparation

Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.