본문 바로가기

💻 LEETCODE14

[LEETCODE] ChatGPT에게 물어봐서 받은 EASY 목록 Two Sum Reverse Integer Palindrome Number Roman to Integer Longest Common Prefix Valid Parentheses Merge Two Sorted Lists Remove Duplicates from Sorted Array Implement strStr() Search Insert Position Count and Say Maximum Subarray Length of Last Word Plus One Move Zeroes Best Time to Buy and Sell Stock Two Sum II - Input array is sorted Valid Sudoku Remove Element Implement pow(x, n) Merge Sorte.. 2023. 1. 16.
[LEETCODE] Diagonal Traverse Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order. Example 1: Input: mat = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,4,7,5,3,6,8,9] Example 2: Input: mat = [[1,2],[3,4]] Output: [1,2,3,4] Constraints: m == mat.length n == mat[i].length 1 2022. 11. 30.
[LEETCODE] 5. Longest Palindromic Substring Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Explanation: "aba" is also a valid answer. Example 2: Input: s = "cbbd" Output: "bb" Constraints: 1 2022. 11. 30.
[LEETCODE] 1991. Find the Middle Index in Array Given a 0-indexed integer array nums, find the leftmost middleIndex (i.e., the smallest amongst all the possible ones). A middleIndex is an index where nums[0] + nums[1] + ... + nums[middleIndex-1] == nums[middleIndex+1] + nums[middleIndex+2] + ... + nums[nums.length-1]. If middleIndex == 0, the left side sum is considered to be 0. Similarly, if middleIndex == nums.length - 1, the right side sum.. 2022. 11. 24.
[LEETCODE] 20. Valid Parentheses Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Every close bracket has a corresponding open bracket of the same type. Example 1: Input: s = "()" Output: true Example 2: Input: s = "()[].. 2022. 11. 23.
[LEETCODE] 14. Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: strs = ["flower","flow","flight"] Output: "fl" Example 2: Input: strs = ["dog","racecar","car"] Output: "" Explanation: There is no common prefix among the input strings. Constraints: 1 2022. 11. 22.