본문 바로가기

Problem Solving/LeetCode18

[LeetCode] 12. Integer to Roman - Java • 문제 링크 Integer to Roman - LeetCodeCan you solve this real interview question? Integer to Roman - Seven different symbols represent Roman numerals with the following values: Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 Roman numerals are formed by appending the conversions of decimalleetcode.com • 풀이 코드public class Solution { public String intToRoman(int num) { StringBuilder sb = .. 2026. 5. 9.
[LeetCode] 11. Container With Most Water - Java • 문제 링크 Container With Most Water - LeetCodeCan you solve this real interview question? Container With Most Water - You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]). Find two lines that togetleetcode.com • 풀이 코드public class Solution { public int maxArea(int[] height) { int l = 0.. 2026. 5. 8.
[LeetCode] 9. Palindrome Number - Java • 문제 링크 Palindrome Number - LeetCodeCan you solve this real interview question? Palindrome Number - Given an integer x, return true if x is a palindrome, and false otherwise. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Exleetcode.com • 풀이 코드public class Solution { public boolean isPalindrome(int x) { if (x 0); .. 2026. 5. 7.
[LeetCode] 3. Longest Substring Without Repeating Characters - Java • 문제 링크 Longest Substring Without Repeating Characters - LeetCodeCan you solve this real interview question? Longest Substring Without Repeating Characters - Given a string s, find the length of the longest substring without duplicate characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "leetcode.com • 풀이 코드public class Solution { public int lengthOfLongestSubst.. 2026. 5. 6.
[LeetCode] 2. Add Two Numbers - Java • 문제 링크 Add Two Numbers - LeetCodeCan you solve this real interview question? Add Two Numbers - 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 andleetcode.com • 풀이 코드public class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) { .. 2026. 5. 5.
[LeetCode] 1. Two Sum - Java • 문제 링크 Two Sum - LeetCodeCan you solve this real interview question? 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 notleetcode.com • 풀이 코드import java.util.HashMap;import java.util.Map;public class Solution { public int[] twoSum(int[.. 2026. 5. 4.