JAVA/Coding Test Study151 [Easy] LeetCode - no.169 Majority Element : Java https://leetcode.com/problems/majority-element/description/?envType=study-plan-v2&envId=top-interview-150 문제과반수를 차지하는 숫자를 return할 것(n / 2보다 많이 출현하는 숫자 찾기)Example 2:Input: nums = [2,2,1,1,1,2,2] Output: 2 풀이import java.util.*;import java.util.Map.*;class Solution { public int majorityElement(int[] nums) { int len = (nums.length % 2 == 0) ? nums.length / 2 : nums.length / 2 + 1; .. 2024. 10. 13. [Easy] LeetCode - no.26 Remove Duplicates from Sorted Array : Java https://leetcode.com/problems/remove-duplicates-from-sorted-array/description/?envType=study-plan-v2&envId=top-interview-150 문제nums라는 배열에서 중복되는 숫자를 지운 후, 남은 nums의 값의 개수를 return할 것이 때 nums의 0번째 index부터 중복되지 않은 숫자들이 나열되어 있어야 함Example 1:Input: nums = [1,1,2] Output: 2, nums = [1,2,_] Explanation: Your function should return k = 2, with the first two elements of nums being 1 and 2 respectively. It .. 2024. 10. 13. [Easy] LeetCode - no.27 Remove Element : Java https://leetcode.com/problems/remove-element/description/?envType=study-plan-v2&envId=top-interview-150 문제nums라는 int 배열에서 val에 해당하는 값을 삭제한 후, 남은 값들의 개수를 return할 것이 때 nums의 0번째 인덱스부터 val을 제외한 숫자들이 채워져 있어야 함 (순서 상관X) 풀이import java.util.*;class Solution { public int removeElement(int[] nums, int val) { List list = new ArrayList(); for (int n : nums) { if (n !=.. 2024. 10. 13. [Easy] LeetCode - no.88 Merge Sorted Array : Java https://leetcode.com/problems/merge-sorted-array/description/?envType=study-plan-v2&envId=top-interview-150 문제오름차순으로 정렬되어 있는 nums1과 nums2라는 int 배열을 하나의 오름차순으로 정렬된 int 배열로 합칠 것(nums1에 값을 저장할 것) 풀이import java.util.*;class Solution { public void merge(int[] nums1, int m, int[] nums2, int n) { List list = new ArrayList(); for (int i = 0; i ArrayList와 Colletions.sort() 사용ArrayLis.. 2024. 10. 13. [Lv.2] 프로그래머스 - 주식가격 : Java 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 이해하기참고한 블로그⬇️ [프로그래머스] 주식가격 - java (Stack 활용)[프로그래머스 코딩테스트] 주식가격 - Stack을 활용한 문제 풀이velog.io 큐가 아닌 스택을 활용해야겠다! 까지는 생각했지만, 막상 구현에서 막혔다.인덱스를 가지고 풀이하는 방식을 참고하였다. 첫번째 숫자는 1이고, stack이 비어있으니 인덱스 0을 push한다.두번째 숫자는 2이고, stack.peek()한 인덱스의 값( = 1 )보다 크기에 가격이 떨어지지 않은 것으로 생각하고 인덱스 1을 push한다.세번째 숫자.. 2024. 9. 1. [Lv.0] 프로그래머스 - 평행 : Java 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 이해하기너무 기본이지만 기울기와 평행 조건부터 다시 정리하였다. 기울기 구하는 법 어렵지 않아요!안녕하세요, 홍재룡수학학원입니다. 수평선 또는 수평면에 대한 기울어짐 정도를 나타내는 기울기! 기울기 ...blog.naver.com 두 직선의 위치관계 - 평행, 일치, 수직두 직선의 위치관계는 중학교 1학년 때 두 직선의 위치관계에서 공부했어요. 이때는 그냥 위치 관계의 종류에 대해서만 공부했죠. 평행, 일치, 수직, 한 점에서 만나는 경우요. 이 글에서는 직선mathbang.net 처음에 잘못 생각하였던 점.. 2024. 6. 21. 이전 1 ··· 3 4 5 6 7 8 9 ··· 26 다음