Problem Solving/LeetCode

문제Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.Notice that the solution set must not contain duplicate triplets. Example 1:Input: nums = [-1,0,1,2,-1,-4]Output: [[-1,-1,2],[-1,0,1]]Explanation: nums[0] + nums[1] + nums[2] = (-1) + 0 + 1 = 0.nums[1] + nums[2] + nums[4] = 0 + 1 + (-1) = 0..
문제Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Let these two numbers be numbers[index1] and numbers[index2] where 1 1 2 .Return the indices of the two numbers, index1 and index2, added by one as an integer array [index1, index2] of length 2.The tests are generated such that there is..
문제A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers.Given a string s, return true if it is a palindrome, or false otherwise. Example 1:Input: s = "A man, a plan, a canal: Panama"Output: trueExplanation: "amanaplanacanal..
문제Products of Array Discluding SelfGiven an integer array nums, return an array output where `output[i]` is the product of all the elements of nums except `nums[i]`.Each product is guaranteed to fit in a 32-bit integer.Follow-up: Could you solve it in 𝑂(𝑛) time without using the division operation?Example 1:Input: nums = [1,2,4,6]Output: [48,24,12,8]Example 2:Input: nums = [-1,0,1,2,3]Output: ..
분류: 문자열 / 문제271. String Encode and DecodeDesign an algorithm to encode a list of strings to a single string. The encoded string is then decoded back to the original list of strings.Please implement encode and decode Example 1:Input: ["neet","code","love","you"]Output: ["neet","code","love","you"]Example 2:Input: ["we","say",":","yes"]Output: ["we","say",":","yes"]Constraints:`0 `0 `strs[i]` cont..
분류: 문자열 / 문제 916. Decoded String at Index You are given an encoded string s. To decode the string to a tape, the encoded string is read one character at a time and the following steps are taken: If the character read is a letter, that letter is written onto the tape. If the character read is a digit d, the entire current tape is repeatedly written d - 1 more times in total. Given an integer k, r..
분류: 스택, 문자열 / 문제 문제 링크 Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results. Example 1: Input: s = "bcabc" Output: "abc" Example 2: Input: s = "cbacdcbc" Output: "acdb" Constraints: 1
분류: 큐 / 문제 문제 링크 Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: Input: s = "pwwkew" Output: 3 Explanation: The answer is "wke", with the length of 3. No..
thecloer
'Problem Solving/LeetCode' 카테고리의 글 목록