반응형

분류 전체보기 619

[프로그래머스][JS / Javascript] 땅따먹기

https://school.programmers.co.kr/learn/courses/30/lessons/12913 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 백준 9465번 스티커 문제와 상당히 유사하다 두 줄 짜리 스티커가 네 줄 짜리 땅으로 바뀌었을 뿐.. [💠 Class를 밀어보자/Class 4] - [BOJ][C++] 백준 9465번: 스티커 동적계획법(Dynamic Programming, DP)를 이용한다. dp[i][j] 는 i행 j열까지 뛰었을 때 얻을 수 있는 최대 점수를 의미한다 바로 직전 줄에서 자신과 같은 열을 제외한 모든(3개) ..

[BOJ][C++] 백준 14888번: 연산자 끼워넣기

https://www.acmicpc.net/problem/14888 14888번: 연산자 끼워넣기 첫째 줄에 수의 개수 N(2 ≤ N ≤ 11)가 주어진다. 둘째 줄에는 A1, A2, ..., AN이 주어진다. (1 ≤ Ai ≤ 100) 셋째 줄에는 합이 N-1인 4개의 정수가 주어지는데, 차례대로 덧셈(+)의 개수, 뺄셈(-)의 개수, 곱 www.acmicpc.net 문제 N개의 수로 이루어진 수열 A1, A2, ..., AN이 주어진다. 또, 수와 수 사이에 끼워넣을 수 있는 N-1개의 연산자가 주어진다. 연산자는 덧셈(+), 뺄셈(-), 곱셈(×), 나눗셈(÷)으로만 이루어져 있다. 우리는 수와 수 사이에 연산자를 하나씩 넣어서, 수식을 하나 만들 수 있다. 이때, 주어진 수의 순서를 바꾸면 안 된..

[DreamHack] 드림핵 웹해킹: command-injection-1

https://dreamhack.io/wargame/challenges/44/ command-injection-1 특정 Host에 ping 패킷을 보내는 서비스입니다. Command Injection을 통해 플래그를 획득하세요. 플래그는 flag.py에 있습니다. Reference Introduction of Webhacking dreamhack.io 문제 특정 Host에 ping 패킷을 보내는 서비스입니다. Command Injection을 통해 플래그를 획득하세요. 플래그는 flag.py에 있습니다. 문제파일 더보기 #!/usr/bin/env python3 import subprocess from flask import Flask, request, render_template, redirect fro..

[프로그래머스][SQL] 그룹별 조건에 맞는 식당 목록 출력하기

https://school.programmers.co.kr/learn/courses/30/lessons/131124 MEMBER_PROFILE와 REST_REVIEW 테이블에서 리뷰를 가장 많이 작성한 회원의 리뷰들을 조회하는 SQL문을 작성해주세요. 회원 이름, 리뷰 텍스트, 리뷰 작성일이 출력되도록 작성해주시고, 결과는 리뷰 작성일을 기준으로 오름차순, 리뷰 작성일이 같다면 리뷰 텍스트를 기준으로 오름차순 정렬해주세요. 풀이 먼저 가장 많은 리뷰수를 작성한 사람을 알아내자 select member_id from rest_review group by member_id order by count(review_id) desc limit 1 이제 이 멤버가 작성한 리뷰들을 골라낸다 limit 연산이 들어간 ..

🍒 SQL/Join 2023.07.05

[TS] type-challenges: 18. Length of Tuple

문제 배열(튜플)을 받아 길이를 반환하는 제네릭 Length를 구현하세요. type tesla = ['tesla', 'model 3', 'model X', 'model Y'] type spaceX = ['FALCON 9', 'FALCON HEAVY', 'DRAGON', 'STARSHIP', 'HUMAN SPACEFLIGHT'] type teslaLength = Length // expected 4 type spaceXLength = Length // expected 5 풀이 type Length = T['length']; 간단하게 이렇게 표현했더니 Type 'readonly ["tesla", "model 3", "model X", "model Y"]' does not satisfy the constrai..

[TS] TypeScript Exercises 4 해석 및 풀이

Intro As we introduced "type" to both User and Admin it's now easier to distinguish between them. Once object type checking logic was extracted into separate functions isUser and isAdmin - logPerson function got new type errors. 유저와 어드민에 대해 type을 소개했듯이, 이제 이 둘을 구분하는건 쉬워졌습니다. 로직을 검사하는 객체 타입을 추출해서 isUser과 isAdmin 함수에 분리해서 넣었더니 logPerson 함수에 새로운 타입에러가 생겼습니다 Exercise Figure out how to help TypeScrip..

[TS] type-challenges: 14. First of Array

문제 배열(튜플) T를 받아 첫 원소의 타입을 반환하는 제네릭 First를 구현하세요. type arr1 = ['a', 'b', 'c'] type arr2 = [3, 2, 1] type head1 = First // expected to be 'a' type head2 = First // expected to be 3 풀이 비교적 간단한 문제라서 T[0]을 반환하도록 했는데, 그랬더니 []인경우 never에 대한 케이스에 걸려서 분기처리를 진행해줬다 type First = T extends [] ? never : T[0]; 출처 https://github.com/type-challenges/type-challenges/blob/main/questions/00014-easy-first/README.ko.m..

[TS] TypeScript Exercises 3 해석 및 풀이

Intro Since we already have some of the additional information about our users, it's a good idea to output it in a nice way. 이미 유저의 추가적인 정보를 알고 있기 때문에, 멋진 방법으로 이를 표출하면 좋을 것 같다 Exercise Fix type errors in logPerson function. logPerson function should accept both User and Admin and should output relevant information according to the input: occupation for User and role for Admin. logPerson 함수의 타입에러..

[TS] type-challenges : 11. Tuple to Object

문제 배열(튜플)을 받아, 각 원소의 값을 key/value로 갖는 오브젝트 타입을 반환하는 타입을 구현하세요. 예시 const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const type result = TupleToObject // expected { tesla: 'tesla', 'model 3': 'model 3', 'model X': 'model X', 'model Y': 'model Y'} 풀이 객체의 키도, 값도 T배열의 요소기 때문에 키값 kv가 T[number]에 속해있고 이 것이 키인 동시에 값이라고 명시해주면 해결된다. 이때 T는 string 또는 number 가 포함된 배열이라는 점도 명시해준다. type TupleToObject..

[TS] TypeScript Exercises 2 해석 및 풀이

Introduce All 2 users liked the idea of the community. We should go forward and introduce some order. We are in Germany after all. Let's add a couple of admins. Initially, we only had users in the in-memory database. After introducing Admins, we need to fix the types so that everything works well together. 두명의 유저 전부 커뮤니티의 아이디어가 마음에 들었고, 우리는 이제 소개를 해야합니다. admin 몇명을 추가해봅시다. 처음에 우리는 데이터베이스에만 유저를 저장..

반응형