반응형

Good morning! Here's your coding interview problem for today.

This problem was asked by Uber.

Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.

For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6].

Follow-up: what if you can't use division?

 


(Google번역)

좋은 아침! 오늘의 코딩 인터뷰 문제는 다음과 같습니다.
이 문제는 Uber에서 요청했습니다.
정수 배열이 주어지면 새 배열의 인덱스 i에 있는 각 요소가 i에 있는 것을 제외한 원래 배열의 모든 숫자의 곱이 되도록 새 배열을 반환합니다.
예를 들어 입력이 [1, 2, 3, 4, 5]인 경우 예상 출력은 [120, 60, 40, 30, 24]입니다. 입력이 [3, 2, 1]인 경우 예상 출력은 [2, 3, 6]입니다.
후속 조치: 나눗셈을 사용할 수 없으면 어떻게 합니까?

 


 

매일 문제을 받고 싶다면 아래 링크에서 구독해보세요.

(단, 문제 풀이는 프리미엄 구독자만 받을 수 있음)

https://www.dailycodingproblem.com/

 

Daily Coding Problem

There's a staircase with N steps, and you can climb 1 or 2 steps at a time. Given N, write a function that returns the number of unique ways you can climb the staircase. The order of the steps matters. For example, if N is 4, then there are 5 unique ways:

www.dailycodingproblem.com

 

반응형

(Original)
Good morning! Here's your coding interview problem for today.

This problem was recently asked by Google.

Given a list of numbers and a number k, return whether any two numbers from the list add up to k.

For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.

Bonus: Can you do this in one pass?

 


(Google번역)
숫자 목록과 숫자 k가 주어지면 목록에서 두 숫자의 합이 k가 되는지 여부를 반환합니다.
예를 들어 [10, 15, 3, 7] 및 17의 k가 주어지면 10 + 7은 17이므로 true를 반환합니다.
보너스: 이 작업을 한 번에 수행할 수 있습니까?

 


매일 문제을 받고 싶다면 아래 링크에서 구독해보세요.

(단, 문제 풀이는 프리미엄 구독자만 받을 수 있음)

https://www.dailycodingproblem.com/

 

Daily Coding Problem

There's a staircase with N steps, and you can climb 1 or 2 steps at a time. Given N, write a function that returns the number of unique ways you can climb the staircase. The order of the steps matters. For example, if N is 4, then there are 5 unique ways:

www.dailycodingproblem.com

 


// example
const array = [10, 15, 3, 7]
const k = 17
let result;
let i = 0;
let j = i + 1;

for (; i < array.length; i++) {
  for (; j < array.length; j++) {
    if (array[i] + array[j] === k) {
      result = true;
      break;
    }
  }
  if (result) break;
}
console.log(result);

숫자 배열안에 N개의 숫자가 있을 때,

for 2번 사용하여 최대 N * (N-1) 으로 O(N2) 복잡도를 생각할 수 있다.

그런데 한 번에 수행한다는 의미가... O(N) or O(1) 이 가능하다는 말인지..

 

'2023' 카테고리의 다른 글

sql,nosql,앱개발,정처기,,,230616  (0) 2023.06.18
2023.01.16. Daily Coding Problem: Problem #3 [Medium]  (0) 2023.01.16
2023.01.13.vue build  (0) 2023.01.13
2023.01.12.  (0) 2023.01.12
2023.01.11.vue  (0) 2023.01.11
반응형

vue cil 사용하여 빌 드 후 배포시 참고 자료

https://cli.vuejs.org/guide/deployment.html

 

Deployment | Vue CLI

Deployment General Guidelines If you are using Vue CLI along with a backend framework that handles static assets as part of its deployment, all you need to do is make sure Vue CLI generates the built files in the correct location, and then follow the deplo

cli.vuejs.org

 


일단 배포는 미루고 빌드하며 문제가 생겼던 부분 해결한 방법에 대해서 적는다.

 

##  *.ico, *.jfif 이미지 파일에 대한 오류 ...

img1 [ ico, jfif 파일 에러 ]

webpack을 설치하려다가 기존 vue 프로젝트에 적용하는 것은 단순히 여러 글을 참고해서

설정 파일을 따라서 작성하는 것만으로는 적용할 수 없겠구나 라는 것을 깨달았다.

 

그래서 다시 package.json > scripts > build 부분을

webpack 에서 다시 기본값인 vue-cli-service build 로 수정하였다.

 

그리고 터미널에서

npm run build 실행하였으나 위 img1 과 같은에러가 발생하였다.

ico, jfif 파일을 로더에서 처리할 수 없어서 발생한다고 한다.

로더 설정을 수정하거나 추가하여 ico, jfif 파일도 변환 가능하도록 해야 한다.

 

또한 기본 vue cli 에 포함된 webpack을 확인하여 vue.config.js에 추가하거나 수정 가능한 것을 알게 되었다.

vue inspect 명령어를 사용해서 현재 프로젝트에 설정된 웹팩 옵션들을 확인 할 수 있었다.

터미널에 위 명령어 사용 시 내용이 많으므로, 아래와 같이 다른 파일에 저장하여 확인 하도록 한다.

vue inspect > options.js

options.js 파일에서 내용을 검색하여 아래와 같은 image 부분을 확인 할 수 있었다.

img2 [ vue inspect - config.module.rule('images') ]

해당 부분을 참고해서 vue.config.js 내부에 추가하였으나 type 관련 에러가 발생하여

최종적으로 추가한 설정은 아래와 같다.

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,

  configureWebpack: {
    mode: 'development',
    module: {
      rules: [
        {
          test: /\.(ico|jfif|png|jpe?g|gif|webp|avif|svg)(\?.*)?$/,
          type: 'asset/resource',
          use: [
            {
              loader: 'file-loader',
            },
          ],
          generator: {
            filename: 'img/[name].[hash:8][ext]',
          },
        },
      ],
    },
  },
});

(최대한 빠른 시일내에 해당 에디터를 좀 고치거나 css를 손보거나,,,영 불편하다)

 

vue.config.js 설정 수정한 후 다시 빌드 시 정상적으로 완료되는 것을 확인 가능하다.

 

 

참고 링크

https://cli.vuejs.org/config/#vue-config-js

 

Configuration Reference | Vue CLI

Configuration Reference Global CLI Config Some global configurations for @vue/cli, such as your preferred package manager and your locally saved presets, are stored in a JSON file named .vuerc in your home directory. You can edit this file directly with yo

cli.vuejs.org

https://joshua1988.github.io/vue-camp/webpack/project-setup.html

 

Project Setup | Cracking Vue.js

Vue CLI로 생성한 프로젝트의 웹팩 설정 방법 Vue CLI로 생성한 프로젝트에 웹팩 설정을 변경하려면 어떻게 해야 할까요? 웹팩 설정 확인 & 변경 방법에 대해 알아봅니다. Vue CLI로 생성한 프로젝트와

joshua1988.github.io

https://cli.vuejs.org/config

 

Configuration Reference | Vue CLI

Configuration Reference Global CLI Config Some global configurations for @vue/cli, such as your preferred package manager and your locally saved presets, are stored in a JSON file named .vuerc in your home directory. You can edit this file directly with yo

cli.vuejs.org

 

'2023' 카테고리의 다른 글

2023.01.16. Daily Coding Problem: Problem #3 [Medium]  (0) 2023.01.16
2023.01.14. Daily Coding Problem: Problem #1 [Easy]  (0) 2023.01.16
2023.01.12.  (0) 2023.01.12
2023.01.11.vue  (0) 2023.01.11
클린 코드  (0) 2023.01.10

+ Recent posts