Notice
Recent Posts
Recent Comments
Link
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

동구의_C# & Unity_개발일지

2024.03.20 내일배움캠프 59일차 TIL_Unity (최종 프로젝트, 알고리즘, 기술 면접) 본문

최종 프로젝트

2024.03.20 내일배움캠프 59일차 TIL_Unity (최종 프로젝트, 알고리즘, 기술 면접)

mongle_0l 2024. 3. 19. 23:54

알고리즘 코드카타 42일차

두 개 뽑아서 더하기

문제 설명
정수 배열 numbers가 주어집니다. numbers에서 서로 다른 인덱스에 있는 두 개의 수를 뽑아 더해서 만들 수 있는 모든 수를 배열에 오름차순으로 담아 return 하도록 solution 함수를 완성해주세요.
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution {
    public int[] solution(int[] numbers) {
        List<int> answer = new List <int>();
        for (int i = 0; i < numbers.Length; i++) {
            for(int j = i + 1; j < numbers.Length; j++){
                answer.Add(numbers[i] + numbers[j]);
            }
        }
        answer.Sort();
        return answer.Distinct().ToArray();
    }
}


기술면접 연습하기 11일차

델리게이트(Delegate)의 개념에 대해 설명해주세요.
다른 객체로의 작업을 위임하거나 콜백(callback) 함수를 구현하는 데 사용된다.

함수나 메서드를 변수처럼 다루는 기능을 제공하여 프로그램의 유연성을 높이고 코드의 재사용성을 높일 수 있다.

최종 프로젝트

~ing