본문 바로가기

리트코드10

[LeetCode] 016. 3Sum Closest JAVA 3Sum Closest - LeetCode 3Sum Closest - Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Examp leetcode.com 📍 문제 Given an integer array nums of length n and an integer target, find three integers in nums such that t.. 2023. 1. 5.
[LeetCode] 015. 3Sum JAVA 📍 문제 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. 정수 배열 nums가 주어지면 i != j, i != k, j != k nums[i] + nums[j] + nums[k] == 0. 조금 더 설명을 하자면, 정수 배열인 nums가 주어지면 인덱스가 다른 세 수의 합이 0이 되면 해당 숫자들을 리스트에 담고 그 리스트를 다시 리스트에 담아서 리턴시키면 되.. 2023. 1. 5.
[LeetCode] 013. Roman to Integer JAVA https://leetcode.com/problems/roman-to-integer/ ☀️ 문제 Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. For 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 smallest from left to right. How.. 2022. 12. 30.
[LeetCode] 008. String to Integer (atoi) JAVA String to Integer (atoi) - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 📍 문제 ENG Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++'s atoi function). The algorithm for myAtoi(string s) is as follows: 1️⃣ Read in and igno.. 2022. 12. 21.
[LeetCode]006. Zigzag Conversion JAVA Zigzag Conversion - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 📌 문제 The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then.. 2022. 12. 21.
[LeetCode]007. Reverse Integer JAVA Reverse Integer - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 📌 문제 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 a.. 2022. 12. 19.
[LeetCode]005. Longest Palindromic Substring JAVA Longest Palindromic Substring - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 📌 문제 Given a string s, return the longest palindromic substring in s. 📌 방법 반복문을 통해 문자열의 길이만큼 반복 그 안에서 반복되는 문자열 중 가장 긴 문자열을 출력 팰린드롬은 거꾸로 읽어도 제대로 읽는 것과 같은 낱말, 숫자, 문자열 따라서 반으로 접었을 때에, 양 옆이 같음. 때문에 반복문을 통해 .. 2022. 12. 19.
[LeetCode] 003. Longest Substring Without Repeating Characters JAVA Longest Substring Without Repeating Characters - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 📌 문제 Given a string s, find the length of the longest substring without repeating characters. 📌 방법 컬렉션을 이용하여 풀이 그 중에서 Set의 HashSet을 이용하여 풀이 1️⃣ 최댓값 max 선언 및 초기화 2️⃣ HashSet을 이용하여 풀이 3️⃣.. 2022. 12. 16.
[LeetCode] 002. Add Two Numbers JAVA Add Two Numbers - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 📌 문제 You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as.. 2022. 12. 16.
[LeetCode] 001. Two Sum JAVA Two Sum - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 📌 문제 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 elem.. 2022. 12. 15.