segment tree C++解Leetcode 3479 Fruits Into Baskets III
線段樹(segment tree)是一種進階的資料結構,可以用來解決一些 LeetCode 難題。
線段樹本質上是一棵二元樹;它可以用二元樹來實現,但更常見的是使用陣列表示。這題需要用到有最大值的線段樹;以及一種尋找第一個不小於target的basket然後更新的方法。
------
Segment tree is an advance data struture which can solve several Leetcode questions.
Segment tree is basically a binary tree, ; it can be implemented by using binary tree, but most frequently its array representation way. This question needs the segment tree with max; and a method which searchs the 1st basket not less than target & then updates it.
[Solution to 3477 Fruits Into Baskets II]https://leetcode.com/problems/fruits-into-baskets-ii/solutions/7045085/easy-subtraction-beats-100/
沒有留言:
張貼留言