본문 바로가기

Algorithm80

[LeetCode] 1544. Make The String Great (java) ✏️ 문제 Given a string s of lower and upper case English letters. A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where: 0 2024. 4. 6.
[PROGRAMMERS] SQL 고득점 Kit - SELECT (MySQL, Oracle) ✏️ [Lv. 1] 조건에 맞는 도서 리스트 출력하기 BOOK 테이블에서 2021년에 출판된 '인문' 카테고리에 속하는 도서 리스트를 찾아서 도서 ID(BOOK_ID), 출판일 (PUBLISHED_DATE) 을 출력하는 SQL문을 작성해주세요. 결과는 출판일을 기준으로 오름차순 정렬해주세요. 👾 구현 -- MySQL SELECT book_id, date_format(published_date, '%Y-%m-%d') as published_date from book where category = '인문' and published_date like '2021%' order by published_date; --Oracle SELECT book_id, to_char(published_date, 'yyyy-mm.. 2024. 1. 10.
[LeetCode] 1913. Maximum Product Difference Between Two Pairs (java) ✏️ 문제 The product difference between two pairs (a, b) and (c, d) is defined as (a * b) - (c * d). For example, the product difference between (5, 6) and (2, 7) is (5 * 6) - (2 * 7) = 16. Given an integer array nums, choose four distinct indices w, x, y, and z such that the product difference between pairs (nums[w], nums[x]) and (nums[y], nums[z]) is maximized. Return the maximum such product dif.. 2023. 12. 19.
[BOJ] 5430. AC (python) ✏️ 문제 선영이는 주말에 할 일이 없어서 새로운 언어 AC를 만들었다. AC는 정수 배열에 연산을 하기 위해 만든 언어이다. 이 언어에는 두 가지 함수 R(뒤집기)과 D(버리기)가 있다. 함수 R은 배열에 있는 수의 순서를 뒤집는 함수이고, D는 첫 번째 수를 버리는 함수이다. 배열이 비어있는데 D를 사용한 경우에는 에러가 발생한다. 함수는 조합해서 한 번에 사용할 수 있다. 예를 들어, "AB"는 A를 수행한 다음에 바로 이어서 B를 수행하는 함수이다. 예를 들어, "RDD"는 배열을 뒤집은 다음 처음 두 수를 버리는 함수이다. 배열의 초기값과 수행할 함수가 주어졌을 때, 최종 결과를 구하는 프로그램을 작성하시오. 🤖 알고리즘 #구현 #자료구조 #문자열 🤯 풀이 방법 할일이 없으면 언어를 만드는 선영.. 2023. 12. 18.
[LeetCode] #1887. Reduction Operations to Make the Array Elements Equal ✏️ 문제 Given an integer array nums, your goal is to make all elements in nums equal. To complete one operation, follow these steps: Find the largest value in nums. Let its index be i (0-indexed) and its value be largest. If there are multiple elements with the largest value, pick the smallest i.Find the next largest value in nums strictly smaller than largest. Let its value be nextLargest.Reduce .. 2023. 11. 19.
[LeetCode] 876. Middle of the Linked List (java) ✏️ 문제 Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. 🤖 알고리즘 #링크드리스트 #투포인터 🤯 풀이 방법 주어진 리스트의 전체 길이를 구하고 절반까지 도달할 때까지 next로 이동하는 방식으로 풀었다. 메모리 효율이 좋지 않아서 확인해보니 투포인터를 이용해서 복사해서 길이를 구할 필요 없이 인덱스만 이용해서 한 바퀴만 돌게 푸는 게 더 효율적인 방법인 듯! 👾 구현 코드 (자바) class Solution { public ListNode middleNode(ListNode head) { in.. 2023. 10. 30.
728x90