목록분류 전체보기 (66)
아무고토 몰라효
문제문제명: Find All Numbers Disappeared in an Array출처: LeetCode 448 문제 설명Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums.예시 입출력Example 1:Input: nums = [4,3,2,7,8,2,3,1]Output: [5,6]Example 2:Input: nums = [1,1] Output: [2]제약사항1 1 고민문제를 처음 봤을 때 생각은 이랬다:"아, 1부터 n까지의 숫자 중에서 빠진 것들을 찾는 문제구나!"처음에는 ..
문제0과 1로 이루어진 어떤 문자열 x에 대한 이진 변환을 다음과 같이 정의합니다.x의 모든 0을 제거합니다.x의 길이를 c라고 하면, x를 "c를 2진법으로 표현한 문자열"로 바꿉니다.예를 들어, x = "0111010"이라면, x에 이진 변환을 가하면 x = "0111010" -> "1111" -> "100" 이 됩니다.0과 1로 이루어진 문자열 s가 매개변수로 주어집니다. s가 "1"이 될 때까지 계속해서 s에 이진 변환을 가했을 때, 이진 변환의 횟수와 변환 과정에서 제거된 모든 0의 개수를 각각 배열에 담아 return 하도록 solution 함수를 완성해주세요.Constraints:s의 길이는 1 이상 150,000 이하입니다.s에는 '1'이 최소 하나 이상 포함되어 있습니다.고민반복문을 돌아..
문제JadenCase란 모든 단어의 첫 문자가 대문자이고, 그 외의 알파벳은 소문자인 문자열입니다. 단, 첫 문자가 알파벳이 아닐 때에는 이어지는 알파벳은 소문자로 쓰면 됩니다. (첫 번째 입출력 예 참고)문자열 s가 주어졌을 때, s를 JadenCase로 바꾼 문자열을 리턴하는 함수, solution을 완성해주세요.Example 1:| s | return || --- | --- || "3people unFollowed me" | "3people Unfollowed Me" |sreturn"3people unFollowed me""3people Unfollowed Me""for the last week""For The Last Week"Constraints:s는 길이 1 이상 200 이하인 문자열입니다.s..
415. Add Strings문제Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string.You must solve the problem without using any built-in library for handling large integers (such as BigInteger). You must also not convert the inputs to integers directly.Example 1:Input: num1 = "11", num2 = "123"Output: "134"Example 2:Input: num1 = "456", num2 = "77..
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 of "abcde" while "aec" is not).Example 1:Input: s = "abc", t = "..
Find the Difference문제You are given two strings s and t.String t is generated by random shuffling string s and then add one more letter at a random position.Return the letter that was added to t.Example 1:Input: s = "abcd", t = "abcde"Output: "e"Explanation: 'e' is the letter that was added.Example 2:Input: s = "", t = "y"Output: "y"Constraints:0 t.length == s.length + 1s and t consist of lowerca..

https://leetcode.com/problems/reverse-string문제Write a function that reverses a string. The input string is given as an array of characters s.You must do this by modifying the input array in-place with O(1) extra memory.Example 1:Input: s = ["h","e","l","l","o"] Output: ["o","l","l","e","h"]Example 2:Input: s = ["H","a","n","n","a","h"] Output: ["h","a","n","n","a","H"]Constraints:- 1 ⁵- s[i] is ..

문제Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:1. Open brackets must be closed by the same type of brackets.2. Open brackets must be closed in the correct order.3. Every close bracket has a corresponding open bracket of the same type.Example 1:Input: s = "()"Output: trueExample 2:Input: s = "()..

https://leetcode.com/problems/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 - ..

https://leetcode.com/problems/roman-to-integer문제Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.SymbolValueI1V5X10L50C100D500M1000For example, 2 is written as II in Roman numeral, just two ones added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II.Roman numerals are usually written largest to smalle..