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

Commit eebee95

Browse files
committed
Create README - LeetHub
1 parent b214a24 commit eebee95

File tree

1 file changed

+26
-0
lines changed
  • 1721-swapping-nodes-in-a-linked-list

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<h2><a href="https://leetcode.com/problems/swapping-nodes-in-a-linked-list/">1721. Swapping Nodes in a Linked List</a></h2><h3>Medium</h3><hr><div><p>You are given the <code>head</code> of a linked list, and an integer <code>k</code>.</p>
2+
3+
<p>Return <em>the head of the linked list after <strong>swapping</strong> the values of the </em><code>k<sup>th</sup></code> <em>node from the beginning and the </em><code>k<sup>th</sup></code> <em>node from the end (the list is <strong>1-indexed</strong>).</em></p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong>Example 1:</strong></p>
7+
<img alt="" src="https://assets.leetcode.com/uploads/2020/09/21/linked1.jpg" style="width: 400px; height: 112px;">
8+
<pre><strong>Input:</strong> head = [1,2,3,4,5], k = 2
9+
<strong>Output:</strong> [1,4,3,2,5]
10+
</pre>
11+
12+
<p><strong>Example 2:</strong></p>
13+
14+
<pre><strong>Input:</strong> head = [7,9,6,6,7,8,3,0,9,5], k = 5
15+
<strong>Output:</strong> [7,9,6,6,8,7,3,0,9,5]
16+
</pre>
17+
18+
<p>&nbsp;</p>
19+
<p><strong>Constraints:</strong></p>
20+
21+
<ul>
22+
<li>The number of nodes in the list is <code>n</code>.</li>
23+
<li><code>1 &lt;= k &lt;= n &lt;= 10<sup>5</sup></code></li>
24+
<li><code>0 &lt;= Node.val &lt;= 100</code></li>
25+
</ul>
26+
</div>

0 commit comments

Comments
(0)

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