🔗 문제 https://www.acmicpc.net/problem/11660 11660번: 구간 합 구하기 5 첫째 줄에 표의 크기 N과 합을 구해야 하는 횟수 M이 주어진다. (1 ≤ N ≤ 1024, 1 ≤ M ≤ 100,000) 둘째 줄부터 N개의 줄에는 표에 채워져 있는 수가 1행부터 차례대로 주어진다. 다음 M개의 줄에는 네 www.acmicpc.net 💻 코드 package org.kyhslam.bakjun; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public clas..
https://leetcode.com/problems/array-partition-i/ Array Partition I - 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 💻 코드 (Java) package org.kyhslam.leetCode; import java.util.ArrayList; import java.util.Arrays; public class leet_561 { public static int arrayPairSum(int[] nums) { i..
🔗 문제 https://leetcode.com/problems/3sum/ 3Sum - 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 📝 풀이 순서대로 정렬하면 풀이가 더 간단해진다. 중복저장되는 것을 방지하기 위해 아래 코드 추가 💻 코드 (java) class Solution { public List threeSum(int[] nums) { List answerList = new ArrayList(); Arrays.sort(nums); for (int i = ..
🔗 문제 https://leetcode.com/problems/trapping-rain-water/ Trapping Rain Water - 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 📝 풀이 '투 포인터'를 사용하여 왼쪽, 오른쪽에서 가운데 방향으로 가면서 각 최대높이에서 해당 높이 값을 계산하면 된다. 💻 코드 (java) class Solution { public int trap(int[] height) { int answer = 0; int left_m..
🔗 문제 https://leetcode.com/problems/two-sum/ 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 📝 포인트 타겟에서 첫번째 수를 빼면 두번째 수를 바로 알 수 있다. 그래서 두 번째 수를 키로하고 INDEX를 값으로 하면 키로 값을 바로 찾을 수 있다. 💻 코드(Java) class Solution { public int[] twoSum(int[] nums, int target) { HashMap nums_map =..
🔗 문제 https://leetcode.com/problems/valid-palindrome/ Valid Palindrome - 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 📝 포인트 char[]로 변환해서 문자, 숫자 검사 후, List에 담았다 Character.isLetterOrDigit 💻 코드 class Solution { public boolean isPalindrome(String s) { boolean answer = true; if(s == n..
🔗 문제 링크 : https://leetcode.com/problems/most-common-word/ Most Common Word - 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 금지된 단어 제외한 가장 흔하게 등장하는 단어를 출력. 대소문자 구분하지 않는다. 구두점(마침표,쉼표 등) 는 무시 📝 포인트 정규식 사용법 collections.Counter() 사용법 replaceAll("\\p{Punct}", " ") // 구두점 제거 List keySetL..