OAmaster
— / 11已做

Amazon 近期在新岗位 OA 里穿插了一类 MERN (MongoDB + Express + React + Node) 全栈 bug-fix 题, 和算法题完全不同:

  • 给你一个完整的 e-commerce / MovieDB / VibeShop 仓库
  • 后端有若干 broken endpoint, 前端有若干交互 bug
  • 你需要在 read-only test 通过的前提下, 修 controllers/*.js / routes/*.js / React 组件

因为这类题不能用 Python/Java/C++ Tabs 表达, 也不算"算法 OA", 单独抽到本文件存档. 主算法库见 Amazon OA.


修复 password change 端点的安全 bug:

  • 当前 password 没校验, 直接允许换
  • 新密码绕过强度校验 (需 ≥8 chars + 大写 + 小写 + 数字 + 特殊字符)
  • 没发 4-digit 验证码就允许换
  • 3 次失败应锁 60 秒

涉及端点:

  • POST /api/auth/change-password/initiate
  • POST /api/auth/change-password/verify
  • POST /api/auth/change-password/update

考点: bcrypt password verification, regex strength check, in-memory rate limit + 临时锁, JWT auth middleware.


GET /api/products/catalog 不返回所有 csv, bulk-upload 不持久化.

考点: fs.readdir 而非 fs.readFile, csv-parser stream + collection.insertMany (不是 insertOne), 路由顺序问题 (/search 必须在 /:productId 之前).


POST /api/products 缺 tag 数量校验 (≥3), DELETE /api/products/:id 删除不持久化 (缺 filter {_id: ObjectId(id)}).

考点: mongoose validation, ObjectId 转换, 401/400 error code 区分.


(算法穿插题, 已收录在主算法库. 见 Amazon OA Problem 13.)


POST /api/reviews/:movieId 应:

  1. 扫描评论里的 inappropriateWords 列表 (在 README.md), 命中则 400 + {message, inappropriateWords, isFlagged: true}
  2. Rate limit: 每用户 4 reviews / 60s combined
  3. 同一用户被拒 3 次后 flag 帐号, 禁止再 post/edit

考点: middleware 链式 rate-limit (express-rate-limit 或自实现), in-memory Map<userId, count>, regex word boundary \\b.


修 backend, 让 watchlist add / list / remove 工作.

涉及端点:

  • GET /api/watchlist/ (列出当前用户全部)
  • GET /api/watchlist/check/:movieId
  • POST /api/watchlist/add (rate limit 10 ops / 2 min)
  • DELETE /api/watchlist/remove/:movieId

考点: Mongoose schema relation (User.watchlist: [ObjectId]), req.user from JWT, populate('movieId').


让用户创建命名 list (除了 default watchlist), 加电影进去, 重命名, 删除.

涉及端点:

  • POST /api/lists/ (create)
  • GET /api/lists/
  • PUT /api/lists/:listId
  • POST /api/lists/:listId/movies
  • DELETE /api/lists/:listId/movies/:movieId

考点: nested ObjectId arrays, unique name per user constraint.


实现 follow actor + 收到新片上映通知:

  • POST /api/follow body {actorId}
  • GET /api/notifications/ (列分页)
  • GET /api/notifications/unread-count
  • PUT /api/notifications/:id/read
  • Admin POST /api/admin/movies + POST /api/admin/movies/:id/launch (触发通知 fan-out)

考点: Notification fan-out 在 movie launch 时遍历所有 followers + insertMany.


修两个 bug:

  1. Basic search case-sensitive + only title (应 case-insensitive, 支持 title/celebs/all filter)
  2. Advanced search filter (year range / rating range / genre array / director / writer) 永远返回 No Matching Results

考点: Mongo $regex + $options: 'i', $and 复合 filter, decimal rating $gte/$lte.


这些题在 HackerRank IDE 环境里跑, install/run/test 通过 npm 触发, 测试用 mocha + chai-http. 实际备题建议:

  • 熟悉 Express middleware + bcrypt + JWT 三件套
  • mongoose populateaggregate
  • React useState + useEffect + Context (前端 task 部分)
  • 不要去改 read-only 的 test 文件 (改了直接 0 分)
Pro 会员

解锁全部 8 道题的解法

题面你已经看到了 — 解法 + 三语代码 + 复杂度推导 + 边界讨论, Pro 解锁.

Pro 解锁全部
  • 📚1000+ 道真实北美 OA, Python / Java / C++ 三语题解
  • 📊个人 dashboard + 进度可视化 + 14 天活跃图
  • 📝题目笔记跨设备同步 + 个人复盘库
  • 🔓随时取消下次续费, Stripe Customer Portal 自助管理
$12/月($98/年, 一次付清省 32%)

≈ 北美 SWE 工资 10 分钟 · LeetCode Premium $35/月 的 23%