[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클럽 코테 스터디 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클럽 코테 스터디 20일차 TIL - 동적계획법 (Dynamic Programming)
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Partition Array for Maximum Sum (출처 하단 표기)비기너 문제가 쉬워서 미들러 문제도 같이 풀어보았다. 문제Given an integer array arr, partition the array into (contiguous) subarrays of length at most k. After partitioning, each subarray has their values changed to become the maximum value of that subarray.Return the largest sum of the given array after partitioning. Test cases are generated so that the answer ..
[99클럽] 99클럽 코테 스터디 19일차 TIL - 동적계획법 (Dynamic Programming)
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Pascal's Triangle (출처 하단 표기) 문제Given an integer numRows, return the first numRows of Pascal's triangle.In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: 제한사항1 입출력 예numRowsreturn5[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]1[[1]] 풀이초기 코드import java.util.*;class Solution { public List> generate(int numRows) { /* 파스칼의 삼각형 ..
[99클럽] 99클럽 코테 스터디 18일차 TIL - 동적계획법 (Dynamic Programming)
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Counting Bits (출처 하단 표기) 문제Given an integer n, return an array ans of length n + 1 such that for each i (0 ), ans[i] is the number of 1's in the binary representation of i. 제한사항0 입출력 예nreturn2[0, 1, 1]5[0, 1, 1, 2, 1, 2] 풀이class Solution { public int[] countBits(int n) { // 2진수로 바꿨을 때 1의 개수 int[] answer = new int[n+1]; StringBuilder sb = new Strin..
[99클럽] 99클럽 코테 스터디 17일차 TIL - 그리디 (Greedy)
·
코딩테스트 연습/99클럽
오늘의 문제Leetcode - Split a String in Balanced Strings (출처 하단 표기) 문제Balanced strings are those that have an equal quantity of 'L' and 'R' characters.Given a balanced string s, split it into some number of substrings such that:Each substring is balanced.Return the maximum number of balanced strings you can obtain. 제한사항2 s[i] is either 'L' or 'R'.s is a balanced string.입출력 예sreturn"RLRRLLRLRL"4"RLRRR..