목록투포인터 (25)
넘치게 채우기
https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/description/leetcode - Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit문제 유형 : 슬라이딩 윈도우, 투 포인터, 데크(deque)문제 난이도 : Medium 문제Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference betwee..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/zWUn6/btsH8Gyr0Ma/FvbZyn48VOMzriI3yQCBV0/img.png)
https://leetcode.com/problems/count-number-of-nice-subarrays/description/leetcode - Count Number of Nice Subarrays문제 유형 : 슬라이딩 윈도우, 투포인터문제 난이도 : Medium 문제Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it.Return the number of nice sub-arrays. 정수배열 nums와 정수 k가 주어집니다. 연속적인 부분배열의 요소에 홀수의 요소가 정확히 k개 있으면, nice한 subarray입니다.nice한 sub..
https://leetcode.com/problems/sum-of-square-numbers/description/leetcode - Sum of Square Numbers문제 유형 : 수학, 투포인터문제 난이도 : Medium 문제Given a non-negative integer c, decide whether there're two integers a and b such that a2 + b2 = c. 음수가 아닌 정수 c가 주어진다. a^2+b^c = c를 만족하는 두 정수 a와 b가 있는지 확인하시오. 풀이가장 기본적으로 떠올릴 수 있는 경우는 a = 0, b = c^(1/2)이다.b가 c의 제곱근인 경우, 바로 true가 나온다. 아니라면, a*a+b*b를 sum이라 하자.sum이 c보다 크면..
https://leetcode.com/problems/reverse-string/description/leetcode - Reverse String문제 유형 : 문자열 처리, 투 포인터문제 난이도 : Easy 문제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 with O(1) extra memory. 역문자열로 만드는 함수를 작성하시오. 배열로 주어집니다.O(1)공간복잡도여야 합니다. 풀이left가 right보다 작은동안, swap()해주면 된다.left++right-- 코드C++cla..
https://leetcode.com/problems/score-of-a-string/description/leetcode - Score of a String문제 유형 : 문자열 처리, 투 포인터문제 난이도 : Easy 문제You are given a string s. The score of a string is defined as the sum of the absolute difference between the ASCII values of adjacent characters.Return the score of s. 문자열 s를 받는다.문자열의 점수는 두 인접한 문자들의 아스키 값의 차들의 합으로 한다.s의 점수를 구하시오. 풀이0, 11, 2...n-2, n-1의 아스키 값의 차들을 구해서 누적시킨다..
https://leetcode.com/problems/boats-to-save-people/description/leetcode - Boats to Save People문제 유형 : 정렬, 그리디, 투 포인터문제 난이도 : Medium 문제You are given an array people where people[i] is the weight of the ith person, and an infinite number of boats where each boat can carry a maximum weight of limit. Each boat carries at most two people at the same time, provided the sum of the weight of those peopl..
https://leetcode.com/problems/compare-version-numbers/description/leetcode - Compare Version Numbers문제 유형 : 문자열 처리, 투 포인터, 슬라이딩 윈도우문제 난이도 : Medium 문제Given two version numbers, version1 and version2, compare them.Version numbers consist of one or more revisions joined by a dot '.'. Each revision consists of digits and may contain leading zeros. Every revision contains at least one character. Revi..
https://leetcode.com/problems/largest-positive-integer-that-exists-with-its-negative/description/leetcode - Largest Positive Integer That Exists With Its Negative문제 유형 : 정렬, 구현, 그리디, 투포인터문제 난이도 : Easy 문제Given an integer array nums that does not contain any zeros, find the largest positive integer k such that -k also exists in the array.Return the positive integer k. If there is no such integer, ..
https://leetcode.com/problems/minimum-common-value/description/ Leetcode - Minimum Common Value 문제 유형 : 그리디, 투포인터 문제 난이도 : Easy 문제 Given two integer arrays nums1 and nums2, sorted in non-decreasing order, return the minimum integer common to both arrays. If there is no common integer amongst nums1 and nums2, return -1. Note that an integer is said to be common to nums1 and nums2 if both arrays h..
https://leetcode.com/problems/middle-of-the-linked-list/description/ Leetcode - Middle of the Linked List 문제 유형 : 연결리스트, 투포인터 문제 난이도 : Easy 문제 Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. 단순 연결리스트의 헤드가 주어진다. 중간 노드를 반환하라. 두 개의 중앙 노드가 있다면, 두 번째 중앙 노드를 반환하라. 풀이 투 포인터를 이용해서 풀어주면 된다. 두 칸씩 이동하는 fast 한 칸..