반응형

릿코드 3

[LeetCode] 5. Longest Palindromic Substring (Java)

문제 Given a string s, return the longest palindromic substring in s. 문자열 s가 주어지면, s에서 가장 긴 회문(palindromic) 부분 문자열을 반환하세요. 회문이란? 회문(回文) 또는 팰린드롬(palindrome)은 거꾸로 읽어도 제대로 읽는 것과 같은 문장이나 낱말, 숫자, 문자열(sequence of characters) 등이다. 보통 낱말 사이에 있는 띄어쓰기나 문장 부호는 무시한다. 출처: 회문 - 위키백과 Example 1: Input: s = "babad" Output: "bab" Explanation: "aba" is also a valid answer.Example 2: Input: s = "cbbd" Output: "bb"제약 ..

[LeetCode] 4. Median of Two Sorted Arrays (Java)

문제 Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. 크기가 각각 m 및 n인 두 개의 정렬된 배열 nums1 및 num2가 주어질 때, 두 개의 정렬된 배열의 중간값을 반환합니다. The overall run time complexity should be O(log (m+n)). 전체 시간복잡도는 O(log(m+n))이어야 합니다. Example 1: Input: nums1 = [1,3], nums2 = [2] Output: 2.00000 Explanation: merged array = [1,2,3] and median is 2.Example 2:..

[LeetCode] 3. Longest Substring Without Repeating Characters (Java)

문제 Given a string s, find the length of the longest substring without repeating characters. 문자열 s가 주어지면, 반복되는 문자가 없는 가장 긴 부분 문자열의 길이를 찾으세요. 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 ..

반응형