frontend-challenges
frontend-challenges copied to clipboard
FrontendChallenges is a collection of frontend interview questions and answers. It is designed to help you prepare for frontend interviews. It's free and open source.
index.ts ```ts index.ts export function twoSum(nums: number[], target: number): number[] { const countMap: Record = {}; for (let i = 0; i < nums.length; i++) { countMap[nums[i]] = i; }...
index.js ```js index.js export function debounce(func, delay) { // write your code here let timer; return function(...args) { if(timer) clearTimeout(timer) timer = setTimeout(() => { func.apply(this, args) }, delay) }...
index.ts ```ts index.ts export function topKFrequent(nums: number[], k: number): number[] { const frequencyMap = new Map(); nums.map((num) => { const count = frequencyMap.has(num) ? frequencyMap.get(num) : 0; frequencyMap.set(num, (count ??...
index.js ```js index.js export function instanceOfClass(obj, targetClass) { if(typeof obj !== 'object' || obj==null){ return false } const instace = Object.getPrototypeOf(obj); if( instace === targetClass.prototype){ return true; } return instanceOfClass(...
styles.css ```css styles.css .parent { height: 200px; width: 200px; border: 2px solid black; background-color: yellow; overflow: hidden; position: relative; } .rocket { height: 50px; width: 50px; font-size: 50px; position: fixed;...
styles.css ```css styles.css body { font-family: sans-serif; } :root { --minVw: 320px; --maxVw: 720px; --minSize: 16px; --maxSize: 32px; } h1 { font-size: clamp(var(--minSize), calc((var(--maxSize) - var(--minSize)) / (var(--maxVw) - var(--minVw))...
index.ts ```ts index.ts export function groupAnagrams(strs: string[]): string[][] { const anagramMap = new Map(); for (let i = 0; i < strs.length; i++) { const current = strs[i]; const sortedStr...
styles.css ```css styles.css body { font-family: sans-serif; } main { display: flex; flex-direction: column; gap: 12px; padding: 20px; align-items: center; } button { display: flex; align-items: center; appearance: none; background-color:...
styles.css ```css styles.css body { font-family: sans-serif; -webkit-font-smoothing: auto; -moz-font-smoothing: auto; -moz-osx-font-smoothing: grayscale; font-smoothing: auto; text-rendering: optimizeLegibility; font-smooth: always; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; } main { display: flex; flex-direction: column;...
index.js ```js index.js /** * @param {number[]} height * @return {number} */ export function trap(height) { let n = height.length; let leftMax = [] let rightMax = []; leftMax[0] =...