[99클럽] 99클럽 코테 스터디 30일차 TIL - 문자열
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Shuffle String (출처 하단 표기) 문제You are given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.Return the shuffled string. 제한사항s.length == indices.length == n1 s consists of only lowercase English letters.0 All values of indices are unique.입출력 예sindicesretu..
[99클럽] 99클럽 코테 스터디 29일차 TIL - 문자열
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Count Items Matching a Rule (출처 하단 표기) 문제You are given an array items, where each items[i] = [typei, colori, namei] describes the type, color, and name of the ith item. You are also given a rule represented by two strings, ruleKey and ruleValue.The ith item is said to match the rule if one of the following is true:ruleKey == "type" and ruleValue == typei.ruleKey == "color" and r..
[99클럽] 99클럽 코테 스터디 28일차 TIL - 배열 (Array)
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Find Words Containing Character (출처 하단 표기)문제 푸는 데 오랜 시간이 걸리지 않아 한 문제를 더 풀었다. 해당 문제는 여기에 따로 정리하였다. 문제You are given a 0-indexed array of strings words and a character x.Return an array of indices representing the words that contain the character x.Note that the returned array may be in any order. 제한사항1 1 x is a lowercase English letter.words[i] consists only of lowercase English l..
[99클럽] 99클럽 코테 스터디 27일차 TIL - 배열 (Array)
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Number of Good Pairs (출처 하단 표기) 문제Given an array of integers nums, return the number of good pairs.A pair (i, j) is called good if nums[i] == nums[j] and i  j. 제한사항1 1 입출력 예numsreturn[1,2,3,1,1,3]4[1,1,1,1]6[1,2,3]0 풀이import java.util.*;class Solution { public int numIdenticalPairs(int[] nums) { int answer = 0; Map map = new HashMap(); // ..
[99클럽] 99클럽 코테 스터디 26일차 TIL - 배열 (Array)
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Shuffle the Array, Subrectangle Queries (출처 하단 기재)비기너 문제를 풀 때 얼마 걸리지 않아 미들러 문제를 풀었는데, 미들러 문제도 쉬운 편이었다. 비기너문제Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn].Return the array in the form [x1,y1,x2,y2,...,xn,yn]. 제한사항1 nums.length == 2n1 입출력 예numsnreturn[2,5,1,3,4,7]3[2,3,5,4,1,7][1,2,3,4,4,3,2,1]4[1,4,2,3,3,2,4,1][1,1,2,2]2[1,2,1,2] 풀이class S..
[99클럽] 99클럽 코테 스터디 25일차 TIL - 그래프 (Graph)
·
코딩테스트 연습/99클럽
오늘의 문제프로그래머스 - 순위 (출처 하단 표기) 문제n명의 권투선수가 권투 대회에 참여했고 각각 1번부터 n번까지 번호를 받았습니다. 권투 경기는 1대1 방식으로 진행이 되고, 만약 A 선수가 B 선수보다 실력이 좋다면 A 선수는 B 선수를 항상 이깁니다. 심판은 주어진 경기 결과를 가지고 선수들의 순위를 매기려 합니다. 하지만 몇몇 경기 결과를 분실하여 정확하게 순위를 매길 수 없습니다.선수의 수 n, 경기 결과를 담은 2차원 배열 results가 매개변수로 주어질 때 정확하게 순위를 매길 수 있는 선수의 수를 return 하도록 solution 함수를 작성해주세요. 제한사항선수의 수는 1명 이상 100명 이하입니다.경기 결과는 1개 이상 4,500개 이하입니다.results 배열 각 행 [A, B..
[99클럽] 99클럽 코테 스터디 24일차 TIL - 그래프 (Graph)
·
코딩테스트 연습/99클럽
오늘의 문제프로그래머스 - 네트워크원래 문제는 이 문제였지만 시간이 푸는 데 시간이 오래 걸리지 않아 다른 문제를 풀었다. 문제네트워크란 컴퓨터 상호 간에 정보를 교환할 수 있도록 연결된 형태를 의미합니다. 예를 들어, 컴퓨터 A와 컴퓨터 B가 직접적으로 연결되어있고, 컴퓨터 B와 컴퓨터 C가 직접적으로 연결되어 있을 때 컴퓨터 A와 컴퓨터 C도 간접적으로 연결되어 정보를 교환할 수 있습니다. 따라서 컴퓨터 A, B, C는 모두 같은 네트워크 상에 있다고 할 수 있습니다.컴퓨터의 개수 n, 연결에 대한 정보가 담긴 2차원 배열 computers가 매개변수로 주어질 때, 네트워크의 개수를 return 하도록 solution 함수를 작성하시오. 제한사항컴퓨터의 개수 n은 1 이상 200 이하인 자연수입니다...
[99클럽] 99클럽 코테 스터디 23일차 TIL - 이분탐색 (Binary Search)
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Count Negative Numbers in a Sorted Matrix (출처 하단 표기) 문제Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid. 제한사항m == grid.lengthn == grid[i].length1 -100 입출력 예gridreturn[[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]8[[3,2],[1,0]]0 풀이완전 탐색으로만 푼 코드import java.util.*;class Solution { pu..
[99클럽] 99클럽 코테 스터디 22일차 TIL - 이분탐색 (Binary Search)
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Search Insert Position (출처 하단 표기) 문제Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You must write an algorithm with O(log n) runtime complexity. 제한사항1 -10 ⁴  ⁴nums contains distinct values sorted in ascending order.-10 ⁴  ⁴입출력 예numstargetreturn[1, 3, 5,..
[99클럽] 99클럽 코테 스터디 21일차 TIL - 동적계획법 (Dynamic Programming)
·
코딩테스트 연습/99클럽
오늘의 문제백준 - 1로 만들기 (출처 하단 표기)원래 오늘 비기너 문제는 이 문제였지만 시간이 오래 걸리지 않아 다른 문제를 하나 더 풀었다. 문제정수 X에 사용할 수 있는 연산은 다음과 같이 세 가지이다.X가 3으로 나누어 떨어지면, 3으로 나눈다.X가 2로 나누어 떨어지면, 2로 나눈다.1을 뺀다.정수 N이 주어졌을 때, 위와 같은 연산 세 개를 적절히 사용해서 1을 만들려고 한다. 연산을 사용하는 횟수의 최솟값을 출력하시오. 입력첫째 줄에 1보다 크거나 같고, 10^6보다 작거나 같은 정수 N이 주어진다. 출력첫째 줄에 연산을 하는 횟수의 최솟값을 출력한다. 풀이import java.util.Scanner;public class Main { public static void main(..