✨ 문제 Count Pairs Whose Sum is Less than TargetGiven a 0-indexed integer array nums of length n and an integer target, return the number of pairs (i, j) where 0 and nums[i] + nums[j] . ExampleInput: nums = [-1,1,2,3,1], target = 2Output: 3Explanation: There are 3 pairs of indices that satisfy the conditions in the statement:- (0, 1) since 0 https://leetcode.com/problems/count-pairs-whose-sum-i..
코딩테스트 준비
✨ 문제 K번째수배열 array의 i번째 숫자부터 j번째 숫자까지 자르고 정렬했을 때, k번째에 있는 수를 구하려 합니다.예를 들어 array가 [1, 5, 2, 6, 3, 7, 4], i = 2, j = 5, k = 3이라면array의 2번째부터 5번쨰까지 자르면 [5, 2, 6, 3]입니다.1에서 나온 배열을 정렬하면 [2, 3, 5, 6]입니다.2에서 나온 배열의 3번째 숫자는 5입니다.배열 array, [i, j, k]를 원소로 가진 2차원 배열 commands가 매개변수로 주어질 때, commands의 모든 원소에 대해 앞서 설명한 연산을 적용했을 때 나온 결과를 배열에 담아 return 하도록 solution 함수를 작성해주세요. https://school.programmers.co.kr/le..
✨ 문제 Maximum product of Two Elements in an Array Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1). https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array/description/ ✨ 개념Heap- 힙은 배열을 기반으로 생성.PriorityQueue- 우선순위 큐 ✨ 최종코드public int maxProduct(int[] nums) { Arrays.sort(nums)..
✨ 문제 Minimum Number GameYou are given a 0-indexed integer array nums of even length and there is also an empty array arr. Alice and Bob decided to play a game where in every round Alice and Bob will do one move. The rules of the game are as follows:Every round, first Alice will remove the minimum element from nums, and then Bob does the same.Now, first Bob will append the removed element in the ..
✨ 문제 Valid ParenthesesGiven a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if: 1. Open brackets must be closed by the same type of brackets.2. Open brackets must be closed in the correct order.3. Every close bracket has a corresponding open bracket of the same type. https://leetcode.com/problems/valid-par..
✨ 문제 같은 숫자는 싫어배열 arr가 주어집니다. 배열 arr의 각 원소는 숫자 0부터 9까지로 이루어져 있습니다. 이때, 배열 arr에서 연속적으로 나타나는 숫자는 하나만 남기고 전부 제거하려고 합니다. 단, 제거된 후 남은 수들을 반환할 때는 배열 arr의 원소들의 순서를 유지해야 합니다. 예를 들면,- arr = [1, 1, 3, 3, 0, 1, 1]이면 [1, 3, 0, 1]을 return 합니다.- arr = [4, 4, 4, 3, 3]이면 [4, 3]을 return 합니다.배열 arr에서 연속적으로 나타나는 숫자는 제거하고 남은 수들을 return하는 solution 함수를 완성해 주세요. https://school.programmers.co.kr/learn/courses/30/lessons..
✨ 문제 완주하지 못한 선수수많은 마라톤 선수들이 마라톤에 참여하였습니다. 단 한 명의 선수를 제외하고는 모든 선수가 마라톤을 완주하였습니다.마라톤에 참여한 선수들의 이름이 담긴 배열 participant와 완주한 선수들의 이름이 담긴 배열 completion이 주어질 때, 완주하지 못한 선수의 이름을 return 하도록 solution 함수를 작성해주세요.https://school.programmers.co.kr/learn/courses/30/lessons/42576 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 처음에는 파라미터로 받은 participan..