분류 전체보기
-
[Sorting] 56. Merge IntervalsSW 정글/운영체제 2024. 10. 24. 00:13
https://leetcode.com/problems/merge-intervals/description/Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input. Example 1:Input: intervals = [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]Explanation: Since intervals [1,3] and [2,6] overlap, merge..
-
[Two Pointer] 392. Is SubsequenceSW 정글/알고리즘 2024. 10. 23. 22:26
https://leetcode.com/contest/leetcode-weekly-contest-3/problems/is-subsequence/ Given two strings s and t, return true if s is a subsequence of t, or false otherwise.A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence ..
-
[stack] 20. Valid ParenthesesSW 정글/알고리즘 2024. 10. 23. 16:46
https://leetcode.com/problems/valid-parentheses/description/ 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:..
-
[String] 14. Longest Common Prefix / startswith() 함수SW 정글/알고리즘 2024. 10. 23. 15:34
https://leetcode.com/problems/longest-common-prefix/description/ 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. Constra..
-
[String] 412. Fizz BuzzSW 정글/알고리즘 2024. 10. 23. 14:14
https://leetcode.com/problems/fizz-buzz/description/ Given an integer n, return a string array answer (1-indexed) where:answer[i] == "FizzBuzz" if i is divisible by 3 and 5.answer[i] == "Fizz" if i is divisible by 3.answer[i] == "Buzz" if i is divisible by 5.answer[i] == i (as a string) if none of the above conditions are true.더보기 1부터 n까지의 숫자를 순서대로 출력합니다.각 숫자에 대해 다음 규칙을 따릅니다:숫자가 3의 배수일 경우: "Fiz..
-
[math] 7. Reverse IntegerSW 정글/알고리즘 2024. 10. 23. 13:53
https://leetcode.com/problems/reverse-integer/description/ Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.Assume the environment does not allow you to store 64-bit integers (signed or unsigned). Example 1:Input: x = 123Output: 321Example 2:Input: x = -123Output: -321E..
-
[math] 9. Palindrome-numberSW 정글/알고리즘 2024. 10. 23. 12:49
https://leetcode.com/problems/palindrome-number/description/ Given an integer x, return true if x is a palindrome, and false otherwise. Example 1:Input: x = 121Output: trueExplanation: 121 reads as 121 from left to right and from right to left. Example 2:Input: x = -121Output: falseExplanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindr..
-
[hash] 1. two-sumSW 정글/알고리즘 2024. 10. 23. 11:13
https://leetcode.com/problems/two-sum/ Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.You may assume that each input would have exactly one solution, and you may not use the same element twice.You can return the answer in any order. Example 1:Input: nums = [2,7,11,15], target = 9Output: [0,1]Explanation: Because nums[0] + ..