← Amazon Interview Insights

Amazon·Software Engineer·Technical Phone Screen·Senior

Senior
Jun 2026

Summary

Amazon technical screen for a software engineer role, heavy on ML fundamentals. Four meaty topics back to back, felt more like a grad school oral exam than a typical coding round. Walked out unsure if I'd done well or completely bombed it.

Questions Asked (4)

Q1

Compare L1 and L2 regularization. How do they differ in terms of sparsity, the geometry of their optimization landscapes, and how they handle outliers in the data?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

I knew the sparsity answer cold (L1 pushes weights to zero, L2 shrinks them evenly) but fumbled when they pushed on the geometry angle.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining L1 and L2 regularization and their mathematical forms. Then systematically compare them across the three requested dimensions: sparsity, optimization landscape geometry, and outlier handling. Conclude with practical implications for model selection, especially in the context of software engineering at Amazon.

Pro tip: Emphasize that L1 is preferred for feature selection and interpretability, while L2 is better for handling multicollinearity and outliers; mention that Elastic Net combines both, showing awareness of trade-offs in real-world systems.

1. Define L1 and L2

Briefly state that L1 adds the sum of absolute weights to the loss, while L2 adds the sum of squared weights. Mention their alternative names: Lasso and Ridge.

2. Sparsity

Explain that L1 induces sparsity by driving some weights exactly to zero, effectively performing feature selection. L2 shrinks weights but rarely to zero, so it doesn't produce sparse solutions.

3. Geometry of optimization landscape

Describe how L1's constraint region is a diamond (or polytope) with corners, making it likely for the optimal solution to hit a corner where some coefficients are zero. L2's constraint region is a circle (or hypersphere), so the solution is a smooth trade-off without zero coefficients.

4. Outlier handling

Discuss that L2 is more sensitive to outliers because it squares errors, giving large errors more weight. L1 is more robust to outliers as it penalizes absolute errors, but note that regularization itself is not primarily for outlier handling; robust loss functions are more direct.

5. Practical implications

Summarize when to use each: L1 for sparse, interpretable models; L2 for stability and when all features are relevant; Elastic Net for combining benefits. Relate to Amazon's scale and need for efficient models.

Key Points to Mention

  • L1 regularization adds |w| penalty; L2 adds w^2 penalty.
  • L1 leads to sparse solutions (feature selection), L2 does not.
  • Geometric interpretation: L1 diamond vs L2 circle; corners cause zero coefficients.
  • L2 is more sensitive to outliers due to squared error; L1 is more robust.
  • Regularization strength (lambda) controls trade-off between fit and penalty.
  • Elastic Net combines L1 and L2, useful for correlated features.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

How do you choose between loss functions like MSE, MAE, logistic loss, and cross-entropy for different regression and classification problems? What are the gradient properties you care about?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Felt okay here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by categorizing the problem as regression or classification, then discuss the statistical assumptions and robustness of each loss function. Explain how the choice affects gradient behavior, optimization, and alignment with business metrics, and tie it back to practical trade-offs like outlier sensitivity and convergence speed.

Pro tip: Emphasize that loss functions should mirror the evaluation metric and business objective; for example, using MAE when outliers are noise, or focal loss for class imbalance. Mention that gradient properties like boundedness and smoothness directly impact training stability and convergence.

1. Identify the problem type

Determine if the task is regression (predicting continuous values) or classification (predicting discrete classes). This narrows the loss function choices to MSE/MAE for regression and logistic loss/cross-entropy for classification.

2. Consider data characteristics and assumptions

Assess the presence of outliers, noise distribution, and class balance. For regression, MSE assumes Gaussian noise and is sensitive to outliers, while MAE assumes Laplacian noise and is robust. For classification, cross-entropy assumes well-separated classes and penalizes confident wrong predictions heavily.

3. Analyze gradient properties

Examine the gradient of each loss: MSE has linear gradients (constant for large errors), MAE has constant gradients (subgradient at zero), logistic loss has gradients that vanish for correct confident predictions, and cross-entropy has gradients that are large for wrong confident predictions. These properties affect convergence speed and stability.

4. Align with business metrics and optimization

Choose a loss that correlates with the ultimate evaluation metric (e.g., MAE for MAE metric, cross-entropy for log loss). Consider optimization ease: smooth losses like MSE and cross-entropy are easier for gradient descent, while non-smooth MAE may require subgradient methods.

5. Summarize trade-offs and justify choice

Conclude by summarizing the trade-offs: robustness vs. efficiency, convergence speed, and interpretability. Justify your choice based on the specific problem context and constraints.

Key Points to Mention

  • MSE vs. MAE: MSE penalizes large errors more, sensitive to outliers; MAE is robust but has constant gradient, which can slow convergence near optimum.
  • Logistic loss vs. cross-entropy: logistic loss is for binary classification, cross-entropy generalizes to multi-class; both are convex and have well-behaved gradients.
  • Gradient properties: MSE gradient is proportional to error, MAE gradient is sign-based, logistic/cross-entropy gradients are error times input, vanishing for correct confident predictions.
  • Impact on optimization: smoothness (Lipschitz continuity) affects learning rate selection and convergence; non-smooth losses may require subgradient or proximal methods.
  • Class imbalance: cross-entropy can be weighted or replaced with focal loss to focus on hard examples.
  • Business alignment: choose loss that directly optimizes the metric of interest, e.g., MAE for median prediction, cross-entropy for probabilistic outputs.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Walk me through PCA: what is it actually optimizing, how do you fit it and then apply it to new data, and how do you decide how many components to keep?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Started with variance maximization, then mentioned the reconstruction error framing as equivalent, which seemed to land well.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining PCA as a dimensionality reduction technique that finds orthogonal directions of maximum variance. Explain the optimization objective (maximizing variance or minimizing reconstruction error), then describe the fitting process (centering, computing covariance matrix, eigendecomposition/SVD) and how to apply to new data (project onto principal components). Finally, discuss methods for choosing the number of components, such as explained variance threshold or scree plot, and mention trade-offs.

Pro tip: Emphasize that PCA is sensitive to feature scaling, so standardization is crucial before applying it. Also, mention that for large datasets, using randomized SVD or incremental PCA can be more efficient than full eigendecomposition.

1. Define PCA and its objective

Explain that PCA is a linear dimensionality reduction technique that seeks orthogonal components maximizing variance. It can be viewed as minimizing reconstruction error or maximizing projected variance.

2. Describe the fitting process

Detail the steps: standardize data (optional but recommended), compute covariance matrix (or use SVD directly), perform eigendecomposition to get eigenvalues and eigenvectors, sort eigenvectors by eigenvalues descending.

3. Explain application to new data

To transform new data, subtract the training mean and project onto the top k eigenvectors (principal components). This yields the reduced representation.

4. Discuss choosing number of components

Mention methods: explained variance ratio (e.g., keep components explaining 95% variance), scree plot elbow method, or cross-validation if used in a supervised pipeline. Also consider downstream task performance.

5. Highlight trade-offs and practical considerations

Note that PCA assumes linearity and may lose interpretability. It's unsupervised, so components may not align with class labels. For large data, use randomized SVD. Always scale features.

Key Points to Mention

  • PCA maximizes variance of projected data or minimizes reconstruction error.
  • Fitting involves computing covariance matrix and eigendecomposition (or SVD).
  • New data is projected onto principal components after centering with training mean.
  • Number of components chosen via explained variance threshold (e.g., 95%) or scree plot elbow.
  • PCA is sensitive to feature scaling; standardization is often necessary.
  • PCA is unsupervised and linear; consider alternatives like t-SNE or autoencoders for non-linear reduction.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

Explain how Random Forests are built, their bias-variance trade-off, the limitations of impurity-based feature importance, and which hyperparameters matter most.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This one tripped me up more than I expected.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer by first explaining the Random Forest algorithm step-by-step, then discuss the bias-variance trade-off and how it relates to ensemble methods, followed by the limitations of impurity-based feature importance and the key hyperparameters. Use concrete examples and connect each part to practical implications for model performance and interpretability.

Pro tip: Emphasize that impurity-based feature importance can be misleading for high-cardinality features and suggest using permutation importance as a more reliable alternative, showing awareness of best practices in model interpretation.

1. Explain how Random Forests are built

Describe the process: bootstrap sampling of the training data, building decision trees on each sample with random feature selection at each split, and aggregating predictions via majority vote (classification) or averaging (regression).

2. Discuss bias-variance trade-off

Explain that individual decision trees have low bias but high variance; Random Forests reduce variance by averaging many decorrelated trees, while bias remains relatively low. Mention that increasing the number of trees reduces variance without increasing bias.

3. Address limitations of impurity-based feature importance

Explain that impurity-based importance (Gini or entropy) is biased towards high-cardinality features and can be misleading when features are correlated. Suggest permutation importance as a more robust alternative.

4. Identify key hyperparameters

List and briefly explain the most important hyperparameters: number of trees (n_estimators), number of features considered at each split (max_features), maximum depth (max_depth), minimum samples per leaf (min_samples_leaf), and bootstrap sampling. Mention that max_features and n_estimators are often the most critical.

Key Points to Mention

  • Bootstrap aggregating (bagging) and random feature selection are core to building Random Forests.
  • Random Forests reduce variance by averaging decorrelated trees, leading to better generalization.
  • Impurity-based feature importance is biased towards high-cardinality features and can be misleading with correlated features.
  • Permutation importance is a more reliable alternative for feature importance.
  • Key hyperparameters: n_estimators, max_features, max_depth, min_samples_leaf, and bootstrap.
  • Increasing n_estimators generally improves performance up to a point, but with diminishing returns and increased computation.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.