본문 바로가기

전체 글39

TIL 24-03-26 오늘의 코드카타 using System; using System.Collections.Generic; using System.Linq; public class Solution { public int[] solution(int[] answers) { int[] answer1 = { 1, 2, 3, 4, 5 }; int[] answer2 = { 2, 1, 2, 3, 2, 4, 2, 5 }; int[] answer3 = { 3, 3, 1, 1, 2, 2, 4, 4, 5, 5 }; int[] scores = new int[3]; for (int i = 0; i < answers.Length; i++) { if (answers[i] == answer1[i % answer1.Length]) scores[0]++; .. 2024. 3. 26.
TIL 2024-03-21 오늘의 코드카타 using System; public class Solution { public string solution(string[] cards1, string[] cards2, string[] goal) { string answer = "Yes"; int index1 = 0; int index2 = 0; for(int i = 0; i < goal.Length; i++) { if(index1 < cards1.Length && goal[i] == cards1[index1]) //goal에 나열 가능한 1번 카드뭉치 { index1++; continue; // 막히면 2번뭉치로 } else if(index2 < cards2.Length && goal[i] == cards2[index2]) { inde.. 2024. 3. 21.
TIL 24-03-18 오늘의 코드카타 using System; using System.Collections.Generic; public class Solution { public int[] solution(int k, int[] score) { int[] answer = new int[score.Length]; List award = new List(); int count = 0; foreach(int s in score) { award.Add(s); award.Sort(); if(award.Count>k) award.RemoveAt(0); // 리스트에서 지우는 메서드 answer[count++] = award[0]; } return answer; } } 이전 기록을 지우기 위해 RemoveAt을 알게 되었는데 실제 프로젝.. 2024. 3. 19.
TIL 24-03-14 오늘의 코드카타 콜라 문제 using System; public class Solution { public int solution(int a, int b, int n) { int answer = 0; while (n > a -1) { answer += (n / a) * b; n = (n / a) * b + n % a; } return answer; } } 처음엔 for문을 사용하려 했지만 바꾸지 않은 잔병 처리를 위해 while문으로 교체했다 오늘의 모의기술면접 Q. 가비지 컬렉터를 회피하기 위한 전략은 무엇이 있나요? 메모리 사용패턴을자체를 최적화 시키는 것입니다 제 지식으로 자쥬쓰이는 방법으론 objectpool을 이용해 오브젝트를 미리 할당하여 지속적인 발생과 파괴를 피하는것이고 이는 지금보다 한참.. 2024. 3. 14.