[FE] Pham Van Phu Thinh (thinhphamdn1999@gmail.com)#287
Open
thinhphamdn1999 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Solutions for three front-end coding challenges.
Problem 1 — Three ways to sum to N: Three TypeScript implementations of
sum_to_nwith 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
useFetchhook, input validation, real-time conversion, and graceful loading/error states.Problem 3 — Messy React code review: A refactored
WalletPagecomponent addressing 10 bugs and performance issues in the original code: undefined variable reference (lhsPriority), inverted filter condition,getPriorityrecreated per render,blockchaintyped asany, unusedformattedBalancesvariable, missingblockchainfield in the interface, array index used as Reactkey, sort comparator missing the equal case,childrensilently dropped, andpriceslisted as a stale dependency. AREADME.mddocuments each issue and its fix.How to run
ts-node src/problem1/three-ways-to-sum-to-n.tsand verify all three functions return correct values for edge cases (0, 1, negative, large n)cd src/problem2 && npm install && npm run dev— verify currency list loads, swap direction works, and amounts convert correctlysrc/problem3/solution.tsxcompiles cleanly and the README accurately describes each fix