컴퓨터공학/LeetCode 1000

    [LeetCode] 627. Swap Salary

    627. Swap Salary Easy SQL Schema Table: Salary +-------------+----------+ | Column Name | Type | +-------------+----------+ | id | int | | name | varchar | | sex | ENUM | | salary | int | +-------------+----------+ id is the primary key for this table. The sex column is ENUM value of type ('m', 'f'). The table contains information about an employee. Write an SQL query to swap all 'f' and 'm' val..

    [LeetCode] 1873. Calculate Special Bonus

    1873. Calculate Special Bonus Easy SQL Schema Table: Employees +-------------+---------+ | Column Name | Type | +-------------+---------+ | employee_id | int | | name | varchar | | salary | int | +-------------+---------+ employee_id is the primary key for this table. Each row of this table indicates the employee ID, employee name, and salary. Write an SQL query to calculate the bonus of each em..

    [LeetCode] 796. Rotate String

    796. Rotate String Easy Given two strings s and goal, return true if and only if s can become goal after some number of shifts on s. A shift on s consists of moving the leftmost character of s to the rightmost position. For example, if s = "abcde", then it will be "bcdea" after one shift. Example 1: Input: s = "abcde", goal = "cdeab" Output: true Example 2: Input: s = "abcde", goal = "abced" Out..

    [LeetCode] 487. Max Consecutive Ones II

    487. Max Consecutive Ones II Medium Given a binary array nums, return the maximum number of consecutive 1's in the array if you can flip at most one 0. Example 1: Input: nums = [1,0,1,1,0] Output: 4 Explanation: - If we flip the first zero, nums becomes [1,1,1,1,0] and we have 4 consecutive ones. - If we flip the second zero, nums becomes [1,0,1,1,1] and we have 3 consecutive ones. The max numbe..

    [LeetCode] 140. Word Break II

    140. Word Break II Hard Given a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences in any order. Note that the same word in the dictionary may be reused multiple times in the segmentation. Example 1: Input: s = "catsanddog", wordDict = ["cat","cats","and","sand","dog"] Output: ["cat..

    [LeetCode] 139. Word Break

    139. Word Break Medium Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the dictionary may be reused multiple times in the segmentation. Example 1: Input: s = "leetcode", wordDict = ["leet","code"] Output: true Explanation: Return true because "leetcode" can be segm..

    [LeetCode] 131. Palindrome Partitioning

    131. Palindrome Partitioning Medium Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. Example 1: Input: s = "aab" Output: [["a","a","b"],["aa","b"]] Example 2: Input: s = "a" Output: [["a"]] Constraints: 1 = len(s): self.ans.append(temp.copy()) for i in range(idx, len(s)): if palin(s, idx, i): temp.append(s..

    [LeetCode] 130. Surrounded Regions

    [LeetCode] 130. Surrounded Regions

    130. Surrounded Regions Medium Given an m x n matrix board containing 'X' and 'O', capture all regions that are 4-directionally surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region. Example 1: Input: board = [["X","X","X","X"],["X","O","O","X"],["X","X","O","X"],["X","O","X","X"]] Output: [["X","X","X","X"],["X","X","X","X"],["X","X","X","X"],["X","O",..