LeetCode

    [LeetCode - DiDi Labs 기출 문제] 3Sum Closest

    16. 3Sum Closest Medium Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Example 1: Input: nums = [-1,2,1,-4], target = 1 Output: 2 Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). Example..

    [LeetCode] 1328. Break a Palindrome

    1328. Break a Palindrome Medium Given a palindromic string of lowercase English letters palindrome, replace exactly one character with any lowercase English letter so that the resulting string is not a palindrome and that it is the lexicographically smallest one possible. Return the resulting string. If there is no way to replace a character to make it not a palindrome, return an empty string. A..

    [LeetCode] 653. Two Sum IV - Input is a BST

    [LeetCode] 653. Two Sum IV - Input is a BST

    653. Two Sum IV - Input is a BST Easy Given the root of a Binary Search Tree and a target number k, return true if there exist two elements in the BST such that their sum is equal to the given target. Example 1: Input: root = [5,3,6,2,4,null,7], k = 9 Output: true Example 2: Input: root = [5,3,6,2,4,null,7], k = 28 Output: false Constraints: The number of nodes in the tree is in the range [1, 10..

    [LeetCode] 16. 3Sum Closest

    16. 3Sum Closest Medium Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Example 1: Input: nums = [-1,2,1,-4], target = 1 Output: 2 Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). Example..

    [LeetCode] 531. Lonely Pixel I

    [LeetCode] 531. Lonely Pixel I

    531. Lonely Pixel I Medium Given an m x n picture consisting of black 'B' and white 'W' pixels, return the number of black lonely pixels. A black lonely pixel is a character 'B' that located at a specific position where the same row and same column don't have any other black pixels. Example 1: Input: picture = [["W","W","B"],["W","B","W"],["B","W","W"]] Output: 3 Explanation: All the three 'B's ..

    [LeetCode] 623. Add One Row to Tree

    [LeetCode] 623. Add One Row to Tree

    623. Add One Row to Tree Medium Given the root of a binary tree and two integers val and depth, add a row of nodes with value val at the given depth depth. Note that the root node is at depth 1. The adding rule is: Given the integer depth, for each not null tree node cur at the depth depth - 1, create two tree nodes with value val as cur's left subtree root and right subtree root. cur's original..

    [LeetCode] 112. Path Sum

    [LeetCode] 112. Path Sum

    112. Path Sum Easy Given the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum. A leaf is a node with no children. Example 1: Input: root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22 Output: true Explanation: The root-to-leaf path with the target sum is shown. Example 2..

    [LeetCode] 1578. Minimum Time to Make Rope Colorful

    [LeetCode] 1578. Minimum Time to Make Rope Colorful

    1578. Minimum Time to Make Rope Colorful Medium Alice has n balloons arranged on a rope. You are given a 0-indexed string colors where colors[i] is the color of the ith balloon. Alice wants the rope to be colorful. She does not want two consecutive balloons to be of the same color, so she asks Bob for help. Bob can remove some balloons from the rope to make it colorful. You are given a 0-indexed..