본문 바로가기
728x90

LeetCode22

[LeetCode | Java | Graph 문제 풀이] 1791. Find Center of Star Graph - Solution with edge의 노드값 비교 99 Club 2기 | Java | Beginner⭐ 1791. Find Center of Star Graph🏷 관련 주제 : Graph EasyThere is an undirected star graph consisting of n nodes labeled from 1 to n.A star graph is a graph where there is one center node and exactly n - 1 edges that connect the center node with every other node.You are given a 2D integer array edges where each edges[i] = [ui, vi] indicates that there is an edge between .. 2024. 6. 13.
[LeetCode | Java | Binary Search 문제 풀이] 1351. Count Negative Numbers in a Sorted Matrix - Solution with Loop 99 Club 2기 | Java | Beginner📉 1351. Count Negative Numbers in a Sorted Matrix🏷 관련 주제 : Array Binary Search Matrix Algorithm ComplexityEasyGiven 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.Example 1:Input: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]Output: 8Explanation: There are 8 negative.. 2024. 6. 12.
[LeetCode | Java | Binary Search 문제 풀이] 35. Search Insert Position - Solution with Binary Search 99 Club 2기 | Java | Beginner📥 35. Search Insert Position🏷 관련 주제 : Array Binary SearchEasyGiven 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.Example 1:Input: nums = [1,3,5,6], target = 5Output: 2Example 2:Input: .. 2024. 6. 10.
[LeetCode | Java | 동적 계획법 문제 풀이] 1025. Divisor Game - Solution with Brainteaser 99 Club 2기 | Java | Beginner➗ 1025. Divisor Game🏷 관련 주제 : Math Dynamic Programming Brainteaser Game TheoryEasyAlice and Bob take turns playing a game, with Alice starting first.Initially, there is a number n on the chalkboard.On each player's turn, that player makes a move consisting of:Choosing any x with 0 and n % x == 0.Replacing the number n on the chalkboard with n - x.Also, if a player c.. 2024. 6. 9.
[LeetCode | Java | Dynamic Programming 문제 풀이] 118. Pascal's Triangle - Solution with Recursive Function 99클럽 2기 | 자바 | 비기너△ 118. Pascal's Triangle🏷 Topic : Array Dynamic Programming RecursionEasy 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: Example 1: Input: numRows = 5Output: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]Example 2: Input: numRows = 1Output: [[1]] Constraints:1 A.. 2024. 6. 7.
[LeetCode | Java | Binary Search 문제 풀이] 2824.Count Pairs Whose Sum is Less than Target - Solution with Binary Search 99클럽 2기 | 자바 | 비기너2824.Count Pairs Whose Sum is Less than Target🏷 Topic : Array Two Pointers Binary Search SortingEasyGiven 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] .Example 1:Input: nums = [-1,1,2,3,1], target = 2Output: 3Explanation: There are 3 pairs of indices that satisfy the conditions in the stateme.. 2024. 6. 7.
[LeetCode | Java | Dynamic Programming 문제 풀이] 338. Counting Bits 99클럽 | 비기너2️⃣ 338. Counting Bits🏷 Topic : Dynamic Programming Bit ManipulationEasyGiven 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.Example 1:Input: n = 2Output: [0,1,1]Explanation:0 --> 01 --> 12 --> 10Example 2:Input: n = 5Output: [0,1,1,2,1,2]Explanation:0 --> 01 --> 12 --> 103 --> 114 --> 1005 -->.. 2024. 6. 6.
[LeetCode | Java | Greedy 문제 풀이] 1221. Split a String in Balanced Strings - Solution with Loop of forEach Statement 99클럽 | 비기너👆🤞1221. Split a String in Balanced Strings🏷 Topic : String Greedy CountingEasyBalanced 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.Example 1:Input: s = "RLRRLLRLRL"Output: 4Explanation: s can .. 2024. 6. 5.
[LeetCode | Java | DFS/BFS 문제 풀이] 104. Maximum Depth of Binary Tree - Solution with DFS 99클럽 | 비기너🎄 104. Maximum Depth of Binary Tree🏷 Topic : Tree Binary Tree DFS; Depth-First SearchEasyGiven the root of a binary tree, return its maximum depth.A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Example 1:Input: root = [3,9,20,null,null,15,7]Output: 3Example 2:Input: root = [1,null,2]Output: 2Constraints:Th.. 2024. 6. 3.
728x90


Top