[FE] Coding Challenge - Nhan (Fynn) Truong#193
Open
nhantruong2712 wants to merge 6 commits into99techteam:mainfrom
Open
[FE] Coding Challenge - Nhan (Fynn) Truong#193nhantruong2712 wants to merge 6 commits into99techteam:mainfrom
nhantruong2712 wants to merge 6 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: Three Ways to Sum to N
Solutions:
Iterative Loop (O(n)) - Traditional for-loop approach
Mathematical Formula (O(1)) - Uses Gauss's formula:
n * (n + 1) / 2Number.MAX_SAFE_INTEGER)Recursion (O(n)) - Recursive approach
Assumptions:
Problem 2: Currency Swap Application
Key Features:
Tech Stack:
useTokenPricesfor data fetchingSetup & Run:
cd src/problem2 npm install npm run devDeployment Demo URL https://99-code-challenge-eight.vercel.app/
Preview
Implementation:
useMemoanduseCallbackfor optimizationProblem 3: Messy React Code Analysis & Refactoring
Issues Identified & Fixed:
Type Safety Issues:
anytype for blockchain parameter-> Created
BlockchainNametype andBlockchainEnumfor type safetyLogic Errors:
lhsPriority > -99used undefined variable)amount > 0, not<= 0)-> Fixed filter to properly check priority and positive amounts
Performance Issues:
pricesdependency inuseMemofor sortinguseMemoforformattedBalancesandrows-> Removed redundant dependencies, added proper memoization
Code Quality:
toFixed()vstoFixed(2))childrenin return statement-> Used composite key (
currency-blockchain), proper formatting, included childrenBest Practices:
getPrioritynot memoized-> Memoized
getPrioritywithuseCallback, simplified sort logic