동구의_C# & Unity_개발일지
2024.03.20 내일배움캠프 59일차 TIL_Unity (최종 프로젝트, 알고리즘, 기술 면접) 본문
알고리즘 코드카타 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
'최종 프로젝트' 카테고리의 다른 글
2024.03.22 내일배움캠프 61일차 TIL_Unity (최종 프로젝트, 알고리즘, 기술 면접) (1) | 2024.03.22 |
---|---|
2024.03.21 내일배움캠프 60일차 TIL_Unity (최종 프로젝트, 알고리즘, 기술 면접) (0) | 2024.03.21 |
2024.03.19 내일배움캠프 58일차 TIL_Unity (최종 프로젝트, 알고리즘, 기술 면접) (0) | 2024.03.19 |
2024.03.18 내일배움캠프 57일차 TIL_Unity (최종 프로젝트, 알고리즘, 기술 면접) (0) | 2024.03.18 |
2024.03.15 내일배움캠프 56일차 TIL_Unity (최종 프로젝트, 알고리즘, 기술 면접) (0) | 2024.03.15 |