Algorithm

Algorithm/PTUStudy

4주차. 문자열 반복

2675. 문자열 반복 https://www.acmicpc.net/problem/2675 2675번: 문자열 반복 문자열 S를 입력받은 후에, 각 문자를 R번 반복해 새 문자열 P를 만든 후 출력하는 프로그램을 작성하시오. 즉, 첫 번째 문자를 R번 반복하고, 두 번째 문자를 R번 반복하는 식으로 P를 만들면 된다 www.acmicpc.net 📌문제 문자열 S를 입력받은 후에, 각 문자를 R번 반복해 새 문자열 P를 만든 후 출력하는 프로그램을 작성하시오. 즉, 첫 번째 문자를 R번 반복하고, 두 번째 문자를 R번 반복하는 식으로 P를 만들면 된다. S에는 QR Code "alphanumeric" 문자만 들어있다. QR Code "alphanumeric" 문자는 0123456789ABCDEFGHIJKLM..

Algorithm/PTUStudy

4주차. 배열(주식을 사고팔기 가장 좋은 시점)

11. 주식을 사고팔기 가장 좋은 시점 https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ Best Time to Buy and Sell Stock - LeetCode Best Time to Buy and Sell Stock - You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that leetcode.com ..

Algorithm/PTUStudy

4주차. 배열(자신을 제외한 배열의 곱)

11. 자신을 제외한 배열의 곱 https://leetcode.com/problems/product-of-array-except-self/ Product of Array Except Self - LeetCode Product of Array Except Self - Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. leetcode.com 📌문제 배열을 입력..

Algorithm/PTUStudy

4주차. 배열(배열파티션1)

10. 배열 파티션1 https://leetcode.com/problems/array-partition/ Array Partition - LeetCode Array Partition - Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized. Return the maximized sum. Example 1: Input: nums = [1,4,3,2] Outpu leetcode.com 📌문제 n개의 페어를 이용한 min(a, b)의 합으로 만들 수 있는 가장 큰 수..

Algorithm/PTUStudy

3주차. 더하기 사이클

1110. 더하기사이클 https://www.acmicpc.net/problem/1110 1110번: 더하기 사이클 0보다 크거나 같고, 99보다 작거나 같은 정수가 주어질 때 다음과 같은 연산을 할 수 있다. 먼저 주어진 수가 10보다 작다면 앞에 0을 붙여 두 자리 수로 만들고, 각 자리의 숫자를 더한다. 그 다음, www.acmicpc.net 📌문제 0보다 크거나 같고, 99보다 작거나 같은 정수가 주어질 때 다음과 같은 연산을 할 수 있다. 먼저 주어진 수가 10보다 작다면 앞에 0을 붙여 두 자리 수로 만들고, 각 자리의 숫자를 더한다. 그 다음, 주어진 수의 가장 오른쪽 자리 수와 앞에서 구한 합의 가장 오른쪽 자리 수를 이어 붙이면 새로운 수를 만들 수 있다. 다음 예를 보자. 26부터 시작..

Algorithm/PTUStudy

3주차. 소수찾기

1978. 소수찾기 https://www.acmicpc.net/problem/1978 1978번: 소수 찾기 첫 줄에 수의 개수 N이 주어진다. N은 100이하이다. 다음으로 N개의 수가 주어지는데 수는 1,000 이하의 자연수이다. www.acmicpc.net 📌문제 주어진 수 N개 중에서 소수가 몇 개인지 찾아서 출력하는 프로그램을 작성하시오. - 예제1 📝입력 4 1 3 5 7 💻출력 3 📌풀이 1. 에라토스테네스의 체 (14164 KB,124ms) package week3; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer;..

Algorithm/PTUStudy

3주차. 배열(세수의 합)

09. 세수의 합 https://leetcode.com/problems/3sum/ 3Sum - LeetCode 3Sum - Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain duplicate triplets. Example 1: Input: nums leetcode.com 📌문제 배열을 입력받아 합으로 0을 만들 수 있는 3개의 엘리먼트를 출력하라 - 예제1 📝입력 nums = [-1,0,1,2,..

Algorithm/PTUStudy

3주차. 배열(빗물 트래핑)

08. 빗물 트래핑 https://leetcode.com/problems/trapping-rain-water/ Trapping Rain Water - LeetCode Trapping Rain Water - Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Example 1: [https://assets.leetcode.com/uploads/2018/10/22/rainwatertrap.png] Input: he leetcode.com 📌문제 높이를 입력받아 비 온 후 얼마나 많은 물이 쌓일 수 있는지 ..

Algorithm/PTUStudy

3주차. 배열(두수의 합)

07. 두수의 합 https://leetcode.com/problems/two-sum/ Two Sum - LeetCode Two Sum - Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return leetcode.com 📌문제 덧셈하여 타겟을 만들 수 있는 배열의 두 인덱스를 리턴하라 - 예제1 📝입력 nums = [2,7,11,..

Algorithm/PTUStudy

2주차. 소수구하기

1929. 소수구하기 https://www.acmicpc.net/problem/1929 📌문제 M이상 N이하의 소수를 모두 출력하는 프로그램을 작성하시오. - 예제1 📝입력 3 16 💻출력 3 5 7 11 13 📌풀이 1. 에라토스테네스의 체 (37296 KB,1008 ms) package week2; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class 소수구하기 { public static void main(String[] args) throws IOException { BufferedReader br = ..

지구우중
'Algorithm' 카테고리의 글 목록 (7 Page)