알고리즘/99클럽

✨ 문제 Counting Items Matching a RuleYou 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 ruleValue == colori.rule..
✨ 문제 Find Words Containing CharacterYou 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. https://leetcode.com/problems/number-of-good-pairs/description/   ✨ 최종코드class Solution { public List findWordsContaining(String[] words, char x) { List indi..
✨ 문제 Shuffle the ArrayGiven 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. https://leetcode.com/problems/number-of-good-pairs/description/   ✨ 개념해시 테이블 Hash Table- 매우 효율적인 데이터 구조로, 키(Key)-값(Value) 쌍을 저장하고 검색하는데 사용됨.- 평균적으로 O(1)의 시간 복잡도로 데이터를 삽입, 삭제 및 검색할 수 있음.  ✨ 최종코드class Solution { public int numIdenticalPairs(int[] num..
✨ 문제 Shuffle the ArrayGiven 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]. https://leetcode.com/problems/shuffle-the-array/description/   ✨ 최종코드class Solution { public int[] shuffle(int[] nums, int n) { int[] answerArr = new int[nums.length]; for (int i = 0; i  오늘의 문제는 정수형 배열 nums와 정수..
✨ 문제 Minimum Number of Moves to Seat EveryoneThere are n seats and n students in a room. You are given an array seats of length n, where seats[i] is the position of the ith seat. You are also given the array students of length n, where students[j] is the position of the jth student. https://leetcode.com/problems/minimum-number-of-moves-to-seat-everyone/description/?envType=daily-question&envId=2..
✨ 문제 Find Center of Star GraphThere 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 the nodes ui and vi. Return the center of the given..
✨ 문제 Count Negative Numbers in a Sorted Matrix 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. Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number..
✨ 문제 Search Insert PositionGiven 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. https://leetcode.com/problems/search-insert-position/description/   ✨ 개념이진탐색 Binary Search-   ✨ 최종코드class Solution { public int sea..
✨ 문제 Divisor GameAlice 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 Replacing the number n on the chalkboard with n - x.Also, if a player cannot make a move, they lose the game.Return true if and only if Alice wins the game, assuming both players p..
✨ 문제 Fibonacci NumberGiven 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:The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,F(0) = 0, F(1) = 1F(n) = F(n -..
yeooniyeoon
'알고리즘/99클럽' 카테고리의 글 목록 (2 Page)