Open
Conversation
potrue
reviewed
Feb 28, 2026
| intervals.sort_by_key(|v| v.start); | ||
| intervals.windows(2).all(|w| { | ||
| let (interval, next_interval) = (&w[0], &w[1]); | ||
| interval.end <= next_interval.start |
There was a problem hiding this comment.
Rustは全然わからないんですが読めたので多分読みやすいコードなのだと思います(あんまりレビューできずすみません。。)
ただの感想ですがwindowsなんていうメソッドがRustにはあるんですね。機会があれば学んでみたいです。
hroc135
reviewed
Mar 1, 2026
| 関数のシグネチャがNeetCode採点システムに適合しません。 | ||
| */ | ||
| pub fn can_attend_meetings(intervals: &[Interval]) -> bool { | ||
| let mut time_to_use_room_key_count = BinaryHeap::new(); |
There was a problem hiding this comment.
全部 push し終えたら後は pop するだけなので、ヒープを使わなくても配列をソートするだけで済みそうですね。それで結局 step3 のアルゴリズムに行きつきますね
tokuhirat
reviewed
Mar 1, 2026
Comment on lines
+57
to
+60
| intervals.windows(2).all(|w| { | ||
| let (interval, next_interval) = (&w[0], &w[1]); | ||
| interval.end <= next_interval.start | ||
| }) |
There was a problem hiding this comment.
Rustあまり知らないのですが、L58を書かなければいけないのが少し気になりました。
use itertools::Itertools; とすると、可読性は上がるかなと思いました。
Suggested change
| intervals.windows(2).all(|w| { | |
| let (interval, next_interval) = (&w[0], &w[1]); | |
| interval.end <= next_interval.start | |
| }) | |
| intervals.iter().tuple_windows().all( | |
| |(interval, next_interval)| interval.end <= next_interval.start | |
| ) |
oda
reviewed
Mar 14, 2026
| impl Solution { | ||
| pub fn can_attend_meetings(mut intervals: Vec<Interval>) -> bool { | ||
| intervals.sort_by_key(|v| v.start); | ||
| intervals.windows(2).all(|w| { |
There was a problem hiding this comment.
windows 結構強力ですね。
Python だと itertools.pairwise というのがあるんですが、あまり使われているのをみたことがありません。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
問題: 252. Meeting Rooms(NeetCode版)
次に解く問題: 253. Meeting Rooms Ⅱ(NeetCode版)
ファイルの構成:
./src/bin/<各ステップ>.rs