일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- 메일우유
- DIY
- 3d퍼즐
- 잠실새내
- 뜨아거
- 바질토마토뭐시기
- 누룽지소금빵
- 코테
- 미앤아이
- 취미
- 서울제빵소
- 맛집
- 발더스모드
- 눈알빠지겠네
- 하스스톤
- 송리단
- 토이프로젝트
- 알고리즘테스트
- 메탈퍼즐
- LeetCode
- 천등
- 버즈2프로
- 게임
- 발더스3
- javascript
- 노노그램
- 밥먹고
- 나쫌
- 발더스게이트
- 코딩테스트
- Today
- Total
목록coding test/leetCode (65)
.Zzumbong
난이도 [ 🤔 ] Medium 문제 설명 Given the root of a binary tree, split the binary tree into two subtrees by removing one edge such that the product of the sums of the subtrees is maximized. Return the maximum product of the sums of the two subtrees. Since the answer may be too large, return it modulo 109 + 7. Note that you need to maximize the answer before taking the mod and not after taking it. 문제가 좀 복..
난이도 [ 🤔 ] Medium 문제 설명 Given the root of a binary tree, find the maximum value v for which there exist different nodes a and b where v = |a.val - b.val| and a is an ancestor of b. A node a is an ancestor of b if either: any child of a is equal to b or any child of a is an ancestor of b. 이진트리의 상위, 하위 노드의 a-b 의 최대값을 찾는 문제다. 입출력 예 Example 1: Input: root = [8,3,10,1,6,null,14,null,null,4,7,13] Outpu..
난이도 [ 😊 ] Easy 문제 설명 Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a leaf value sequence. For example, in the given tree above, the leaf value sequence is (6, 7, 4, 9, 8). Two binary trees are considered leaf-similar if their leaf value sequence is the same. Return true if and only if the two given trees with head nodes root1 and root2 are le..
난이도 [ 😊 ] Easy 문제 설명 Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range [low, high]. 2진 트리의 노드 값이 low, high 범위에 들어오면 모두 더해서 return 한다. 입출력 예 Example 1: Input: root = [10,5,15,3,7,null,18], low = 7, high = 15 Output: 32 Explanation: Nodes 7, 10, and 15 are in the range [7, 15]. 7 + 10 + 15 = 32. Exam..
난이도 [ 🤔 ] Medium 문제 설명 Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list. The first node is considered odd, and the second node is even, and so on. Note that the relative order inside both the even and odd groups should remain as it was in the input. You must solve the problem in O(1) extra..
난이도 [ 😊 ] Easy 문제 설명 Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. 단일 linked List 를 준다. list의 중간 부터 return하는데, 중간이 2개 인 경우(짝수 length) 일땐, 2번째 중간 값 부터 return 해준다. 입출력 예 Example 1: Input: head = [1,2,3,4,5] Output: [3,4,5] Explanation: The middle node of the list is node 3. Example 2: Input: head = [..
난이도 [ 🤔 ] Medium 문제 설명 You are given a 0-indexed integer array nums of length n. The average difference of the index i is the absolute difference between the average of the first i + 1 elements of nums and the average of the last n - i - 1 elements. Both averages should be rounded down to the nearest integer. Return the index with the minimum average difference. If there are multiple such indice..
난이도 [ 🤔 ] Medium 문제 설명 Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string. Return the sorted string. If there are multiple answers, return any of them. 문자열 s에 문자가 등장횟수만큼 내림차순 정렬한다. aaaccc, cccaaa 는 둘다 정답이란다. 숫자만 신경쓰면 된다. 입출력 예 Example 1: Input: s = "tree" Output: "eert" Explanation: ..
난이도 [ 🤔 ] Medium 문제 설명 Two strings are considered close if you can attain one from the other using the following operations: Operation 1: Swap any two existing characters. For example, abcde -> aecdb Operation 2: Transform every occurrence of one existing character into another existing character, and do the same with the other character. For example, aacabb -> bbcbaa (all a's turn into b's, and..
난이도 [ 😊 ] Easy 문제 설명 You are given a string s of even length. Split this string into two halves of equal lengths, and let a be the first half and b be the second half. Two strings are alike if they have the same number of vowels ('a','e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'). Notice that s contains uppercase and lowercase letters. Return true if a and b are alike. Otherwise, return false. 짝수 ..
난이도 [ 😊 ] Easy 문제 설명 Given an array of integers arr, return true if the number of occurrences of each value in the array is unique, or false otherwise. int 로 이루어진 arr가 있다. 여기에 나오는 숫자가 발생횟수가 유니크 할때 true이다. 입출력 예 Example 1: Input: arr = [1,2,2,1,1,3] Output: true Explanation: The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two values have the same number of occurrences. 1은 3번, 2는 2번, 3은 1번 ..
난이도 [ 🤔 ] Medium 문제 설명 Implement the RandomizedSet class: RandomizedSet() Initializes the RandomizedSet object. bool insert(int val) Inserts an item val into the set if not present. Returns true if the item was not present, false otherwise. bool remove(int val) Removes an item val from the set if present. Returns true if the item was present, false otherwise. int getRandom() Returns a random ele..
문제 설명 You are given an integer array matches where matches[i] = [winneri, loseri] indicates that the player winneri defeated player loseri in a match. Return a list answer of size 2 where: answer[0] is a list of all players that have not lost any matches. answer[1] is a list of all players that have lost exactly one match. The values in the two lists should be returned in increasing order. Note:..
문제 설명 Given an integer array nums, return the number of all the arithmetic subsequences of nums. A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same. For example, [1, 3, 5, 7, 9], [7, 7, 7, 7], and [3, -1, -5, -9] are arithmetic sequences. For example, [1, 1, 2, 5, 7] is not an arithmetic sequ..
문제 설명 Given an array of integers arr, find the sum of min(b), where b ranges over every (contiguous) subarray of arr. Since the answer may be large, return the answer modulo 109 + 7. 정수 배열에서 min(b)의 합을 구하는데, b는 arr의 모든 연속된 하위 배열이란다. 예제를 보면 이해하 간다. 숫자가 크니까 modulo로 나머지를 리턴하란다. 입출력 예 Example 1: Input: arr = [3,1,2,4] Output: 17 Explanation: Subarrays are [3], [1], [2], [4], [3,1], [1,2], [2,4], [3,..
문제 설명 Given an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once. m x n 문자열 그리드 board가 주어지고, 이 board에 word가 있다면 true를 return 한다. 단어는 가로 세로로 붙어있어야하고 한번 사용한 글자 칸은 두 번이상 사..
문제 설명 Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create. Return the output in any order. String s 를 받아서 개별적으로 소문자나 대문자로 변환하여, 만들 수 있는 모든 문자열을 Array로 반환한다. 순서는 상관없다. 입출력 예 Example 1: Input: s = "a1b2" Output: ["a1b2","a1B2","A1b2","A1B2"] Example 2: Input: s = "3z4" Output: ["3..
문제 설명 A triplet is an array of three integers. You are given a 2D integer array triplets, where triplets[i] = [ai, bi, ci] describes the ith triplet. You are also given an integer array target = [x, y, z] that describes the triplet you want to obtain. To obtain target, you may apply the following operation on triplets any number of times (possibly zero): Choose two indices (0-indexed) i and j (i..
문제 설명 Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". 문자열 배열 중에 가장 긴 공통 접두사를 찾는 문제, 없으면 ''을 리턴 입출력 예 Example 1: Input: strs = ["flower","flow","flight"] Output: "fl" Example 2: Input: strs = ["dog","racecar","car"] Output: "" Explanation: There is no common prefix among the input strings. Constraints 1
문제 설명 You are given an m x n matrix maze (0-indexed) with empty cells (represented as '.') and walls (represented as '+'). You are also given the entrance of the maze, where entrance = [entrancerow, entrancecol] denotes the row and column of the cell you are initially standing at. In one step, you can move one cell up, down, left, or right. You cannot step into a cell with a wall, and you cannot..