Skip to content

feat: add solutions to lc problem: No.1227 #3600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ f(n) = \begin{cases}
\end{cases}
$$

时间复杂度 $O(1)$,空间复杂度 $O(1)$。

<!-- tabs:start -->

#### Python3
Expand Down Expand Up @@ -184,6 +186,24 @@ func nthPersonGetsNthSeat(n int) float64 {
}
```

#### TypeScript

```ts
function nthPersonGetsNthSeat(n: number): number {
return n === 1 ? 1 : 0.5;
}
```

#### Rust

```rust
impl Solution {
pub fn nth_person_gets_nth_seat(n: i32) -> f64 {
return if n == 1 { 1.0 } else { 0.5 };
}
}
```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ f(n) = \begin{cases}
\end{cases}
$$

The time complexity of this solution is $O(1)$, and the space complexity is $O(1)$.

<!-- tabs:start -->

#### Python3
Expand Down Expand Up @@ -178,6 +180,24 @@ func nthPersonGetsNthSeat(n int) float64 {
}
```

#### TypeScript

```ts
function nthPersonGetsNthSeat(n: number): number {
return n === 1 ? 1 : 0.5;
}
```

#### Rust

```rust
impl Solution {
pub fn nth_person_gets_nth_seat(n: i32) -> f64 {
return if n == 1 { 1.0 } else { 0.5 };
}
}
```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
impl Solution {
pub fn nth_person_gets_nth_seat(n: i32) -> f64 {
return if n == 1 { 1.0 } else { 0.5 };
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function nthPersonGetsNthSeat(n: number): number {
return n === 1 ? 1 : 0.5;
}
Loading