👽
frontend-survival
  • Dev Note
    • 🐣1주차
      • 개발환경
      • TypeScript
      • React
      • Testing Library
      • Parcel & ESlint
    • 🐥2주차
      • JSX
      • Virtual DOM
    • 🐥3주차
      • React Component
      • React State
    • 🐥4주차
      • Express
      • fetch API & CORS
      • React Hooks
      • useRef & custom hook
      • usehooks-ts
    • 🐥5주차
      • TDD
      • React Testing Library
      • MSW
    • 🐥6주차
      • external store
      • tsyringe
    • 🐥7주차
      • routing
      • routes
      • router
      • navigation
    • 🐥8주차
      • design system
      • style basics
      • styled components
    • 🐥javascript
      • promise
    • 🐥practice
      • 240102
      • 240103
      • 240423
      • 240424
      • 240426
      • 240430
      • 240501
      • 240506
      • 240508
      • 240512
      • 240514
      • 240515
      • 240714
      • 240716
      • 240717
      • 240808
      • 240813
      • 240816
      • 240819
      • 240820
      • 240826
      • 240904
      • 240906
      • 240909
      • 241021
    • 🐥react
      • state
      • global state
      • Context
      • module state
    • 🐥Next.js
      • app router
    • 🐥algorithm
      • reverse string
      • palindrome
      • reverse int
      • max char
      • chunk
      • anagrams
      • capitalize
      • printing step
      • pyramids
      • vowels
      • matrix spiral
      • queue from stack
    • 🐥css
      • mobile inner height
    • 🐥Clean Architecture
      • object oriented programming
Powered by GitBook
On this page
  1. Dev Note
  2. 🐥practice

240819

문제 : 푸드 파이트 대회 난이도 : Lv.1

풀이

   function solution(food) {
      let leftPart = [];

    // 왼쪽 부분 채우기
    for (let i = 1; i < food.length; i++) {
        let count = Math.floor(food[i] / 2);
        leftPart.push(String(i).repeat(count));
    }

    // 왼쪽을 거꾸로 하여 오른쪽을 만들기
    let leftStr = leftPart.join('');
    let rightStr = leftStr.split('').reverse().join('');

    return leftStr + '0' + rightStr;
}
Previous240816Next240820

Last updated 10 months ago