Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Swift implementation for LCCI 0203 #2616

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
yanglbme merged 2 commits into doocs:main from klever34:swift-impl-lcci-0203
Apr 18, 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
20 changes: 20 additions & 0 deletions lcci/02.03.Delete Middle Node/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,26 @@ var deleteNode = function (node) {
};
```

```swift
/**
* public class ListNode {
* var val: Int
* var next: ListNode?
* init(_ x: Int) {
* self.val = x
* self.next = nil
* }
* }
*/
class Solution {
func deleteNode(_ node: ListNode?) {
guard let node = node, let next = node.next else { return }
node.val = next.val
node.next = next.next
}
}
```

<!-- tabs:end -->

<!-- end -->
20 changes: 20 additions & 0 deletions lcci/02.03.Delete Middle Node/README_EN.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,26 @@ var deleteNode = function (node) {
};
```

```swift
/**
* public class ListNode {
* var val: Int
* var next: ListNode?
* init(_ x: Int) {
* self.val = x
* self.next = nil
* }
* }
*/
class Solution {
func deleteNode(_ node: ListNode?) {
guard let node = node, let next = node.next else { return }
node.val = next.val
node.next = next.next
}
}
```

<!-- tabs:end -->

<!-- end -->
17 changes: 17 additions & 0 deletions lcci/02.03.Delete Middle Node/Solution.swift
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* public class ListNode {
* var val: Int
* var next: ListNode?
* init(_ x: Int) {
* self.val = x
* self.next = nil
* }
* }
*/
class Solution {
func deleteNode(_ node: ListNode?) {
guard let node = node, let next = node.next else { return }
node.val = next.val
node.next = next.next
}
}

AltStyle によって変換されたページ (->オリジナル) /