[FE]: Code challenge solution - Dao Minh Duc#225
Open
felixduc19 wants to merge 2 commits into99techteam:mainfrom
Open
[FE]: Code challenge solution - Dao Minh Duc#225felixduc19 wants to merge 2 commits into99techteam:mainfrom
felixduc19 wants to merge 2 commits into99techteam:mainfrom
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.
Problem 1
In
src/problem1/index.jsyou’ll find three implementations of the same algorithm – summing the firstnnatural numbers:sum_to_n_a: straightforward iterative loop accumulating the sum.sum_to_n_b: recursive version that addsnto the result ofsum_to_n_b(n-1)(note the stack‑overflow warning for largen).sum_to_n_c: constant‑time formula usingn * (n + 1) / 2.Each variant demonstrates a different approach to solving the same mathematical problem and could be used to discuss performance and edge cases.
Problem 2
This directory contains a working Vite‑powered React + TypeScript project, not just a boilerplate. Key points:
tsconfig.json,tsconfig.node.json,.eslintrc.cjs, andvite.config.tsare already set up for linting, type checking, and hot‑module reloading.react,react-dom,axios,styled-componentsalong with TypeScript and ESLint tooling.src/you’ll find a small swap‑UI application:Button,Loading,TokenImage,SwapSection,SelectTokensModal,ConfirmSwapModal)SwapPage) and styling helpers (Flex.styled.ts)constants,enums,types, and utility scripts (e.g.generateImportImages.js)assets/imgwith an importer scriptnpm run devstarts the dev server,npm run buildcompiles TypeScript and bundles via Vite, and there’s a helpergenerateImageObjectscript.The application demonstrates a typical modern React stack with styled‑components and structured folder layout.


Screenshot:
Problem 3
Two versions of a wallet balance page are provided:
Example.tsx– an initial implementation sketching out the component, priority logic, and a placeholderDatasourceclass.RefactorVersion.tsx– a refactored, more polished variant that adds type definitions,makeStylesfor styling, and detailed comments about performance considerations.Both versions use a custom hook
useWalletBalances(imported but not shown) to retrieve balances, then fetch price data fromhttps://interview.switcheo.com/prices.jsonvia theDatasourceclass. Balances are filtered and sorted by blockchain priority and converted toWalletRowelements with formatted amounts and USD values. The refactor includes notes about memoization, avoiding redundant calculations, and key generation for list items.