1. 문제https://leetcode.com/problems/longest-substring-without-repeating-characters/description/?envType=study-plan-v2&envId=top-interview-150 2. 요구사항1) 문자열 s에서 중복된 문자가 없는 부분 문자열 중 가장 긴 문자열의 길이를 구한다. 3. 코드class Solution { int lengthOfLongestSubstring(String s) { // 각 문자와 마지막 인덱스 저장 Map charIndexMap = {}; int maxLength = 0; int windowStart = 0; for(int windowEnd = 0; windowEnd =..
1. 문제https://leetcode.com/problems/find-the-difference-of-two-arrays/description/?envType=study-plan-v2&envId=leetcode-75 2. 요구사항1) 두 정수 배열 nums1와 nums2가 주어진다.2) 각 배열의 고유한 원소드르 중 서로의 배열에 없는 원소를 찾아 반환한다.3) nums1에 있지만, nums2에는 없는 고유한 요소의 리스트와,nums2에 있지만, nums1에는 없는 고유한 요소의 리스트를 반환해야 한다.4) 두 리스트를 2차원 리스트로 반환한다. 3. 코드class Solution { List> findDifference(List nums1, List nums2) { // 중복을 제거하기..
1. 문제https://leetcode.com/problems/find-the-highest-altitude/description/?envType=study-plan-v2&envId=leetcode-75 2. 요구사항1) 고도 변화 기록을 나타내는 정수 리스트 gain이 주어진다.2) gain[i]는 i번째 구간에서 얻은 고도 변화를 의미한다.3) 자전거 타는 사람이 처음 고도 0에서 시작한다고 할 때, 가장 높은 고도를 구한다.4) 처음 고도는 0이다. 3. 코드class Solution { int largestAltitude(List gain) { int maxAltitude = 0; // 최대 고도를 저장할 변수, 초기값은 0 int currentAltitude =..
1. 문제 https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/description/?envType=study-plan-v2&envId=leetcode-75 2. 요구사항1) 각 아이에게 주어진 사탕의 개수를 나타내는 정수 배열 candies가 주어진다.2) 각 아이에게 추가로 줄 수 있는 사탕의 개수를 나타내는 정수 extraCandies도 주어진다.3) 각 아이가 가진 사탕의 수에 extraCandies를 더했을 때 그 아이가 가장 많은 사탕을 가진 아이 중 하나가 될 수 있는지 확인한다.4) 각 아이에 대해 true 또는 false를 담은 배열을 반환한다.5) 가장 많은 사탕을 가진 아이가 될 수 있다면 true, 그렇지..