two pointer

LeetCode

【LeetCode】122. Best Time to Buy and Sell Stock II 解答・解説【Python】

はじめに LeetCodeの問題を解答します。 なるべく、問題の和訳と詳細なコメントを書いています。 余裕があれば、複数のアプローチの解答と、実際の面接を想定して英語での解法やコメントを書いています。 これま...
LeetCode

【LeetCode】 392. Is Subsequence 解答・解説【Python】

はじめに LeetCodeの問題を解答します。 なるべく、問題の和訳と詳細なコメントを書いています。 余裕があれば、複数のアプローチの解答と、実際の面接を想定して英語での解法やコメントを書いています。 ...
LeetCode

【LeetCode】 142. Linked List Cycle II 解答・解説【Python】

はじめに LeetCodeの問題を解答します。 なるべく、問題の和訳と詳細なコメントを書いています。 余裕があれば、複数のアプローチの解答と、実際の面接を想定して英語での解法やコメントを書いています。 ...
LeetCode

【LeetCode】 121. Best Time to Buy and Sell Stock 解答・解説【Python】

はじめに ポイント two poinerを使用 この記事で得られるもの two pointerの初歩的な使い方 時間計算量の改善に関する考え方 この記事が役立ちそうな方 tw...
LeetCode

【LeetCode】986. Interval List Intersections 解答・解説【Python】

問題 原文 You are given two lists of closed intervals, firstList and secondList, where firstList =  and secondLi...
LeetCode

【LeetCode】19. Remove Nth Node From End of List 解答・解説【Python】

学習メモ。 自分の言葉で書くことで理解できていない部分をはっきりさせる。 問題 原文 Given the head of a linked list, remove the nth node from the end of th...
LeetCode

【LeetCode】344. Reverse String 解答・解説【Python】

問題 原文 Write a function that reverses a string. The input string is given as an array of characters s. You must do...
LeetCode

【LeetCode】167. Two Sum II – Input Array Is Sorted 解答・解説【Python】

問題 原文 Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers s...
LeetCode

【LeetCode】283. Move Zeroes 解答・解説【Python】

問題 原文 Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zer...
LeetCode

【LeetCode】15. 3Sum 解答・解説【Python】

問題 原文 Given an integer array nums, return all the triplets , nums, nums] such that i != j, i != k, and j != k, and n...