본문 바로가기

전체 글

(1939)
(C++) - LeetCode (easy) 1399. Count Largest Group https://leetcode.com/problems/count-largest-group/ 전수조사 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 key는 각 자리수 합, value는 그 개수로 map 변수 groupMap, 정답 변수 ans와 largestGroupNum를 선언 후 적잘히 초기화해줍니다. 📔 풀이과정 1. 1 ~ n까지 loop를 수행하며 다음을 수행합니다. 1-1. 현재 원소 i의 각 자리수 합 값을 구합니다. 이 값을 sumDigits에 저장합니다. 1-2. sumDigits를 key로 해 value값을 증가시켜줍니다. 1-3. largestGroupNum에 갱신된 값과 비교해 최댓값을 넣어줍니다. 2. groupMap의 원소를 순회하며 largestGroupNum과 같은 값의 개수..
(C++) - LeetCode (easy) 1394. Find Lucky Integer in an Array https://leetcode.com/problems/find-lucky-integer-in-an-array/description/ Find Lucky Integer in an Array - LeetCode Can you solve this real interview question? Find Lucky Integer in an Array - Given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value. Return the largest lucky integer in the array. If there is no l leetcode.com 간단 구현 문제였습니다..
(C++) - LeetCode (easy) 1389. Create Target Array in the Given Order https://leetcode.com/problems/create-target-array-in-the-given-order/description/ Create Target Array in the Given Order - LeetCode Can you solve this real interview question? Create Target Array in the Given Order - Given two arrays of integers nums and index. Your task is to create target array under the following rules: * Initially target array is empty. * From left to right read n leetcode.c..
(C++) - LeetCode (easy) 1385. Find the Distance Value Between Two Arrays https://leetcode.com/problems/find-the-distance-value-between-two-arrays/description/ Find the Distance Value Between Two Arrays - LeetCode Can you solve this real interview question? Find the Distance Value Between Two Arrays - Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays. The distance value is defined as the number of elements ar l..
(C++) - LeetCode (easy) 1380. Lucky Numbers in a Matrix https://leetcode.com/problems/lucky-numbers-in-a-matrix/description/ 전수조사 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 정답 vector luckies, 행 r, 열 c를 선언 후 적절히 초기화해줍니다. 📔 풀이과정 matrix의 모든 원소를 조사하며 매 원소마다 다음을 수행합니다. 1. 현재 행에서 가장 작은 값을 minRowNum에 저장해줍니다. 2. 현재 열에서 가장 큰 값을 maxRowNum에 저장해줍니다. 3. maxRowNum, minRowNum이 같다면 lucky number이므로 luckies 배열에 현재 원소를 push_back해줍니다. 📔 정답 출력 | 반환 luckies를 반환합니다. 📕 Code 📔 C++ class Solu..
(C++) - LeetCode (easy) 1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/description/ Find a Corresponding Node of a Binary Tree in a Clone of That Tree - LeetCode Can you solve this real interview question? Find a Corresponding Node of a Binary Tree in a Clone of That Tree - Given two binary trees original and cloned and given a reference to a node target in the original..
(SQL) - LeetCode (easy) 1378. Replace Employee ID With The Unique Identifier https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier/ Replace Employee ID With The Unique Identifier - LeetCode Can you solve this real interview question? Replace Employee ID With The Unique Identifier - Table: Employees +---------------+---------+ | Column Name | Type | +---------------+---------+ | id | int | | name | varchar | +---------------+---------+ id is t leetc..
(C++) - LeetCode (easy) 1374. Generate a String With Characters That Have Odd Counts https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts/description/ Generate a String With Characters That Have Odd Counts - LeetCode Can you solve this real interview question? Generate a String With Characters That Have Odd Counts - Given an integer n, return a string with n characters such that each character in such string occurs an odd number of times. The retu..