본문 바로가기

leetcode30

leet code - 1128. Number of Equivalent Domino Pairs(Easy, Hashing, Counting, Combinations) Given a list of dominoes, dominoes[i] = [a, b] is equivalent to dominoes[j] = [c, d] if and only if either (a == c and b == d), or (a == d and b == c) - that is, one domino can be rotated to be equal to another domino.Return the number of pairs (i, j) for which 0 dominoes[i] is equivalent to dominoes[j]. Example 1:Input: dominoes = [[1,2],[2,1],[3,4],[5,6]]Output: 1Example 2:Input: dominoes = [.. 2025. 5. 5.
leet code - 1007. Minimum Domino Rotations For Equal Row(Medium, Greedy, array ) In a row of dominoes, tops[i] and bottoms[i] represent the top and bottom halves of the ith domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.)We may rotate the ith domino, so that tops[i] and bottoms[i] swap values.Return the minimum number of rotations so that all the values in tops are the same, or all the values in bottoms are the same.If it cannot be do.. 2025. 5. 3.
leet code - 560. Subarray Sum Equals K(Medium, hashmap, prefix sum) 560. Subarray Sum Equals K Solved Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.A subarray is a contiguous non-empty sequence of elements within an array. Example 1:Input: nums = [1,1,1], k = 2Output: 2Example 2:Input: nums = [1,2,3], k = 3Output: 2 Constraints:1 -1000 -107 주어진 배열에서 **부분 배열(subarray)**의 합이 정확히 k가 되는 경우의 수를 구하는 문제. in.. 2025. 5. 3.
leet code - 51. N-Queens (Hard, N-Queens) The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle. You may return the answer in any order.Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both indicate a queen and an empty space, respectively. Example 1.. 2025. 4. 28.