Skip to content

[FE] Pham Van Phu Thinh (thinhphamdn1999@gmail.com)#287

Open
thinhphamdn1999 wants to merge 1 commit into
99techteam:mainfrom
thinhphamdn1999:main
Open

[FE] Pham Van Phu Thinh (thinhphamdn1999@gmail.com)#287
thinhphamdn1999 wants to merge 1 commit into
99techteam:mainfrom
thinhphamdn1999:main

Conversation

@thinhphamdn1999

Copy link
Copy Markdown

Summary

Solutions for three front-end coding challenges.

  • Problem 1 — Three ways to sum to N: Three TypeScript implementations of sum_to_n with different time/space tradeoffs: iterative loop O(n), Gauss formula O(1), and tail recursion O(n).

  • Problem 2 — Currency swap form: A React + Vite app (TypeScript, Tailwind, shadcn/ui) that fetches live token prices from the Switcheo API and lets users swap between currencies. Features include live price fetch via a custom useFetch hook, input validation, real-time conversion, and graceful loading/error states.

  • Problem 3 — Messy React code review: A refactored WalletPage component addressing 10 bugs and performance issues in the original code: undefined variable reference (lhsPriority), inverted filter condition, getPriority recreated per render, blockchain typed as any, unused formattedBalances variable, missing blockchain field in the interface, array index used as React key, sort comparator missing the equal case, children silently dropped, and prices listed as a stale dependency. A README.md documents each issue and its fix.

How to run

  • Problem 1: run ts-node src/problem1/three-ways-to-sum-to-n.ts and verify all three functions return correct values for edge cases (0, 1, negative, large n)
  • Problem 2: cd src/problem2 && npm install && npm run dev — verify currency list loads, swap direction works, and amounts convert correctly
  • Problem 3: confirm the refactored src/problem3/solution.tsx compiles cleanly and the README accurately describes each fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant