Skip to content
Closed
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
11 changes: 11 additions & 0 deletions concate_array/arr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from typing import List

Check failure on line 1 in concate_array/arr.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

concate_array/arr.py:1:1: I001 Import block is un-sorted or un-formatted

Check failure on line 1 in concate_array/arr.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (UP035)

concate_array/arr.py:1:1: UP035 `typing.List` is deprecated, use `list` instead

Check failure on line 1 in concate_array/arr.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (INP001)

concate_array/arr.py:1:1: INP001 File `concate_array/arr.py` is part of an implicit namespace package. Add an `__init__.py`.

class Solution:
def getConcatenation(self, nums: List[int]) -> List[int]:

Check failure on line 4 in concate_array/arr.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (UP006)

concate_array/arr.py:4:52: UP006 Use `list` instead of `List` for type annotation

Check failure on line 4 in concate_array/arr.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (UP006)

concate_array/arr.py:4:38: UP006 Use `list` instead of `List` for type annotation

Check failure on line 4 in concate_array/arr.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (N802)

concate_array/arr.py:4:9: N802 Function name `getConcatenation` should be lowercase
l = len(nums)

Check failure on line 5 in concate_array/arr.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E741)

concate_array/arr.py:5:9: E741 Ambiguous variable name: `l`
res = [0] * (2 * l)
for i in range(l):
res[i] = nums[i]
res[i+l] = nums[i]
return res

Check failure on line 11 in concate_array/arr.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W292)

concate_array/arr.py:11:9: W292 No newline at end of file

Check failure on line 11 in concate_array/arr.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W293)

concate_array/arr.py:11:1: W293 Blank line contains whitespace
34 changes: 34 additions & 0 deletions concate_array/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<h2>>Concatenation of Array</a></h2><h3>Easy</h3><hr><p>Given an integer array</code> of length <code>n</code>, you want to create an array <code>ans</code> of length <code>2n</code> where <code>ans[i] == nums[i]</code> and <code>ans[i + n] == nums[i]</code> for <code>0 &lt;= i &lt; n</code> (<strong>0-indexed</strong>).</p>

<p>Specifically, <code>ans</code> is the <strong>concatenation</strong> of two <code>nums</code> arrays.</p>

<p>Return <em>the array </em><code>ans</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [1,2,1]
<strong>Output:</strong> [1,2,1,1,2,1]
<strong>Explanation:</strong> The array ans is formed as follows:
- ans = [nums[0],nums[1],nums[2],nums[0],nums[1],nums[2]]
- ans = [1,2,1,1,2,1]</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [1,3,2,1]
<strong>Output:</strong> [1,3,2,1,1,3,2,1]
<strong>Explanation:</strong> The array ans is formed as follows:
- ans = [nums[0],nums[1],nums[2],nums[3],nums[0],nums[1],nums[2],nums[3]]
- ans = [1,3,2,1,1,3,2,1]
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>n == nums.length</code></li>
<li><code>1 &lt;= n &lt;= 1000</code></li>
<li><code>1 &lt;= nums[i] &lt;= 1000</code></li>
</ul>
Loading