컴퓨터/LeetCode (8) 썸네일형 리스트형 LeetCode 42 Trapping Rain Water Hard [Java] 문제: https://leetcode.com/problems/trapping-rain-water/ Trapping Rain Water - LeetCode Can you solve this real interview question? Trapping Rain Water - Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Example 1: [https://assets.leetcode.com/upl leetcode.com 1. 코드 class Solution { public int trap(int[] .. LeetCode 1 Two Sum Easy [Java] 문제: https://leetcode.com/problems/two-sum/ Two Sum - LeetCode Can 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 not leetcode.com 1. 코드 class Solution { public int[] twoSum(int[] nums, int target) .. LeetCode 5 Longest Palindromic Substring Medium [Java] 문제: https://leetcode.com/problems/longest-palindromic-substring/ = 0 && r < s.length() && s.charAt(l) == s.charAt(r)) { l--; r++; } if(len < r - l - 1) { left = l + 1; len = r - l - 1; } } public String longestPalindrome(String s) { if(s.length() == 1) return s; for(int i = 0; i < s.length() - 1; i++) { sol(s, i, i + 1); sol(s, i, i + 2); } return s.substring(left, left + len); } } 양 끝의 문자가 동일하면.. LeetCode 49 Group Anagrams Medium [Java] 문제: https://leetcode.com/problems/group-anagrams/ Group Anagrams - LeetCode Can you solve this real interview question? Group Anagrams - Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase leetcode.com 1. 코드 class Solution { public List groupAnagrams(Str.. LeetCode 819 Most Common Word Easy [Java] 문제: https://leetcode.com/problems/most-common-word Most Common Word - LeetCode Can you solve this real interview question? Most Common Word - Given a string paragraph and a string array of the banned words banned, return the most frequent word that is not banned. It is guaranteed there is at least one word that is not banned, and tha leetcode.com 1. 코드 class Solution { public String mostCommonWo.. LeetCode 937 Reorder Data in Log File Medium [Java] 문제: https://leetcode.com/problems/reorder-data-in-log-files/ Reorder Data in Log Files - LeetCode Can you solve this real interview question? Reorder Data in Log Files - You are given an array of logs. Each log is a space-delimited string of words, where the first word is the identifier. There are two types of logs: * Letter-logs: All words (except the leetcode.com 1. 코드 class Solution { public .. LeetCode 344 Reverse String Easy [Java] 문제: https://leetcode.com/problems/reverse-string/ Reverse String - LeetCode Can you solve this real interview question? 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 [https://en.wikipedia.org/wiki/In-place_algo leetcode.com 1. 코드 class Solution { public void reverseString(cha.. LeetCode 125 valid-palindrome Easy [Java] 문제: https://leetcode.com/problems/valid-palindrome/ Valid Palindrome - LeetCode Can you solve this real interview question? Valid Palindrome - 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 cha leetcode.com 1. 코드 class Solution { public boolean isPalindro.. 이전 1 다음