[FE]: Code challenge solution - Duong Phuoc Thinh#256
Open
nouu188 wants to merge 3 commits 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
This PR implements and documents solutions for the first three problems in the code challenge.
What Changed
Problem 1: Sum to N
Added three implementations for calculating the sum from
1ton:forloop solution withO(n)time complexity.O(1)time complexity.whileloop solution withO(n)time complexity.This demonstrates multiple valid approaches while making the time complexity tradeoff explicit.
Problem 2: Currency Swap Application
Built a React + TypeScript + Vite currency swap UI with a more polished and maintainable implementation.
Key points:
simulated swap.
DESIGN.md: clean layout, quiet UI chrome, pill controls, focused content hierarchy, and a singleprimary blue action color.
handling, and responsive layout.
localStorage.src/appfor app shell, providers, theme, and global styling.src/features/swapfor swap-specific components, state, hooks, services, and styles.src/sharedfor reusable UI primitives, formatting helpers, and asset helpers.src/datafor typed token data.public/assets/tokensand kept TypeScript data insrc/datato follow Vite conventions.README.mdwith setup steps, assumptions, architectural decisions, and validation commands.Problem 3: Wallet Page Code Review
Added a clear
README.mdexplaining the computational inefficiencies, correctness bugs, and React/TypeScript anti-patterns in the provided walletcomponent.
Covered issues include:
WalletBalancetype.any.useMemodependencies.formattedBalances.NaNUSD values.children.React.FC.classesreference.Also included a refactored version that improves typing, filtering, sorting, formatting, key usage, and derived data handling.