Portpolio/codingtest59 프로그래머스 java lv0. 배열의 평균값 https://school.programmers.co.kr/learn/courses/30/lessons/120817 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.krclass Solution { public double solution(int[] numbers) { double answer = 0; for(int i=0; i 2024. 5. 9. 프로그래머스 lv.0 두수의 나눗셈 java https://school.programmers.co.kr/learn/courses/30/lessons/120806 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.krclass Solution { public int solution(int num1, int num2) { double result = (double) num1 / num2 * 1000; return (int) result; }} 2024. 5. 9. 프로그래머스 lv0. 문자열 반복해서 출력하기 java https://school.programmers.co.kr/learn/courses/30/lessons/181950 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.next(); int n = sc.nextInt(); for (int i=0; i 2024. 4. 1. 프로그래머스 lv0. a와 b 출력하기 java https://school.programmers.co.kr/learn/courses/30/lessons/181951 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); System.out.println("a = " + a); System.out.println.. 2024. 3. 29. 프로그래머스 lv0. 문자열 출력 java https://school.programmers.co.kr/learn/courses/30/lessons/181952 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String a = sc.next(); //입력받는 내용을 a에 저장 System.out.println(a); } } 2024. 3. 29. Leetcode 232번 스택을 이용한 큐 구현 import java.util.Stack; public class P24 { private Stack stack1; private Stack stack2; public P24() { stack1 = new Stack(); stack2 = new Stack(); } public void push(int x) { stack1.push(x); } public int pop() { if (stack2.isEmpty()) { while (!stack1.isEmpty()) { stack2.push(stack1.pop()); } } return stack2.pop(); } public int peek() { if (stack2.isEmpty()) { while (!stack1.isEmpty()) { stack2.pu.. 2023. 12. 31. Leetcode 225번 큐를 이용한 스택 구현 import java.util.LinkedList; import java.util.Queue; public class P23 { private Queue queue1; private Queue queue2; public P23() { queue1 = new LinkedList(); queue2 = new LinkedList(); } public void push(int x) { queue1.offer(x); } public int pop() { while (queue1.size() > 1) { queue2.offer(queue1.poll()); } int topElement = queue1.poll(); swapQueues(); return topElement; } public int top() { wh.. 2023. 12. 31. Leetcode 21번 두 정렬 리스트의 병합 public class solution extends ListNode { solution(int val) { super(val); } public static ListNode mergeTwoLists(ListNode list1, ListNode list2) { // 기저 사례: 둘 중 하나가 비어 있으면 다른 리스트를 반환 if (list1 == null) { return list2; } if (list2 == null) { return list1; } // 현재 노드 값 비교 if (list1.val < list2.val) { // list1의 값이 더 작은 경우 // list1의 다음 노드와 list2를 재귀적으로 병합 list1.next = mergeTwoLists(list1.next, list2).. 2023. 12. 31. Leetcode 234번 팰린드롬 연결 리스트 import java.util.Deque; import java.util.LinkedList; public class P13 extends ListNode{ P13(int val) { super(val); } public static boolean isPalindrome(ListNode head) { // 데크 선언 Deque deque = new LinkedList(); // 연결 리스트의 값을 데크에 저장 ListNode current = head; while (current != null) { deque.addLast(current.val); current = current.next; } // 양쪽에서 값을 하나씩 비교 while (deque.size() > 1) { if (!deque.pollFi.. 2023. 12. 31. Leetcode 121번 주식을 사고팔기 가장 좋은 시점 import java.util.Arrays; public class P12 { public static void main(String args[]) { int[] prices1 = {7,1,5,3,6,4}; int profit1 = maxProfit(prices1); System.out.println(profit1); } public static int maxProfit(int[] prices) { if (prices == null || prices.length 2023. 12. 31. 이전 1 2 3 4 5 6 다음