목록투포인터 (42)
넘치게 채우기
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 한 칸..
https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends/description/ Minimum Length of String After Deleting Similar Ends - LeetCode Can you solve this real interview question? Minimum Length of String After Deleting Similar Ends - Given a string s consisting only of characters 'a', 'b', and 'c'. You are asked to apply the following algorithm on the string any number o..
https://leetcode.com/problems/bag-of-tokens/description/ Leetcode - Bag of Tokens 문제 유형 : 그리디, 투포인터, 정렬 문제 난이도 : Medium 문제 You start with an initial power of power, an initial score of 0, and a bag of tokens given as an integer array tokens, where each tokens[i] donates the value of tokeni. Your goal is to maximize the total score by strategically playing these tokens. In one move, you can play ..
https://leetcode.com/problems/remove-nth-node-from-end-of-list/description/ Remove Nth Node From End of List - LeetCode Can you solve this real interview question? Remove Nth Node From End of List - Given the head of a linked list, remove the nth node from the end of the list and return its head. Example 1: [https://assets.leetcode.com/uploads/2020/10/03/remove_ex1.jpg] leetcode.com Leetcode - R..