Skip to content

feat: add weekly contest 412 #3448

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
Aug 25, 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
@@ -0,0 +1,149 @@
---
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3264.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20I/README.md
---

<!-- problem:start -->

# [3264. K 次乘运算后的最终数组 I](https://leetcode.cn/problems/final-array-state-after-k-multiplication-operations-i)

[English Version](/solution/3200-3299/3264.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20I/README_EN.md)

## 题目描述

<!-- description:start -->

<p>给你一个整数数组&nbsp;<code>nums</code>&nbsp;,一个整数&nbsp;<code>k</code>&nbsp;&nbsp;和一个整数&nbsp;<code>multiplier</code>&nbsp;。</p>

<p>你需要对 <code>nums</code>&nbsp;执行 <code>k</code>&nbsp;次操作,每次操作中:</p>

<ul>
<li>找到 <code>nums</code>&nbsp;中的 <strong>最小</strong>&nbsp;值&nbsp;<code>x</code>&nbsp;,如果存在多个最小值,选择最 <strong>前面</strong>&nbsp;的一个。</li>
<li>将 <code>x</code>&nbsp;替换为&nbsp;<code>x * multiplier</code>&nbsp;。</li>
</ul>

<p>请你返回执行完 <code>k</code>&nbsp;次乘运算之后,最终的 <code>nums</code>&nbsp;数组。</p>

<p>&nbsp;</p>

<p><strong class="example">示例 1:</strong></p>

<div class="example-block">
<p><span class="example-io"><b>输入:</b>nums = [2,1,3,5,6], k = 5, multiplier = 2</span></p>

<p><span class="example-io"><b>输出:</b>[8,4,6,5,6]</span></p>

<p><strong>解释:</strong></p>

<table>
<tbody>
<tr>
<th>操作</th>
<th>结果</th>
</tr>
<tr>
<td>1 次操作后</td>
<td>[2, 2, 3, 5, 6]</td>
</tr>
<tr>
<td>2 次操作后</td>
<td>[4, 2, 3, 5, 6]</td>
</tr>
<tr>
<td>3 次操作后</td>
<td>[4, 4, 3, 5, 6]</td>
</tr>
<tr>
<td>4 次操作后</td>
<td>[4, 4, 6, 5, 6]</td>
</tr>
<tr>
<td>5 次操作后</td>
<td>[8, 4, 6, 5, 6]</td>
</tr>
</tbody>
</table>
</div>

<p><strong class="example">示例 2:</strong></p>

<div class="example-block">
<p><span class="example-io"><b>输入:</b></span>nums = [1,2], k = 3, multiplier = 4</p>

<p><span class="example-io"><b>输出:</b></span>[16,8]</p>

<p><strong>解释:</strong></p>

<table>
<tbody>
<tr>
<th>操作</th>
<th>结果</th>
</tr>
<tr>
<td>1 次操作后</td>
<td>[4, 2]</td>
</tr>
<tr>
<td>2 次操作后</td>
<td>[4, 8]</td>
</tr>
<tr>
<td>3 次操作后</td>
<td>[16, 8]</td>
</tr>
</tbody>
</table>
</div>

<p>&nbsp;</p>

<p><strong>提示:</strong></p>

<ul>
<li><code>1 &lt;= nums.length &lt;= 100</code></li>
<li><code>1 &lt;= nums[i] &lt;= 100</code></li>
<li><code>1 &lt;= k &lt;= 10</code></li>
<li><code>1 &lt;= multiplier &lt;= 5</code></li>
</ul>

<!-- description:end -->

## 解法

<!-- solution:start -->

### 方法一

<!-- tabs:start -->

#### Python3

```python

```

#### Java

```java

```

#### C++

```cpp

```

#### Go

```go

```

<!-- tabs:end -->

<!-- solution:end -->

<!-- problem:end -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
---
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3264.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20I/README_EN.md
---

<!-- problem:start -->

# [3264. Final Array State After K Multiplication Operations I](https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-i)

[中文文档](/solution/3200-3299/3264.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20I/README.md)

## Description

<!-- description:start -->

<p>You are given an integer array <code>nums</code>, an integer <code>k</code>, and an integer <code>multiplier</code>.</p>

<p>You need to perform <code>k</code> operations on <code>nums</code>. In each operation:</p>

<ul>
<li>Find the <strong>minimum</strong> value <code>x</code> in <code>nums</code>. If there are multiple occurrences of the minimum value, select the one that appears <strong>first</strong>.</li>
<li>Replace the selected minimum value <code>x</code> with <code>x * multiplier</code>.</li>
</ul>

<p>Return an integer array denoting the <em>final state</em> of <code>nums</code> after performing all <code>k</code> operations.</p>

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

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [2,1,3,5,6], k = 5, multiplier = 2</span></p>

<p><strong>Output:</strong> <span class="example-io">[8,4,6,5,6]</span></p>

<p><strong>Explanation:</strong></p>

<table>
<tbody>
<tr>
<th>Operation</th>
<th>Result</th>
</tr>
<tr>
<td>After operation 1</td>
<td>[2, 2, 3, 5, 6]</td>
</tr>
<tr>
<td>After operation 2</td>
<td>[4, 2, 3, 5, 6]</td>
</tr>
<tr>
<td>After operation 3</td>
<td>[4, 4, 3, 5, 6]</td>
</tr>
<tr>
<td>After operation 4</td>
<td>[4, 4, 6, 5, 6]</td>
</tr>
<tr>
<td>After operation 5</td>
<td>[8, 4, 6, 5, 6]</td>
</tr>
</tbody>
</table>
</div>

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

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [1,2], k = 3, multiplier = 4</span></p>

<p><strong>Output:</strong> <span class="example-io">[16,8]</span></p>

<p><strong>Explanation:</strong></p>

<table>
<tbody>
<tr>
<th>Operation</th>
<th>Result</th>
</tr>
<tr>
<td>After operation 1</td>
<td>[4, 2]</td>
</tr>
<tr>
<td>After operation 2</td>
<td>[4, 8]</td>
</tr>
<tr>
<td>After operation 3</td>
<td>[16, 8]</td>
</tr>
</tbody>
</table>
</div>

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

<ul>
<li><code>1 &lt;= nums.length &lt;= 100</code></li>
<li><code>1 &lt;= nums[i] &lt;= 100</code></li>
<li><code>1 &lt;= k &lt;= 10</code></li>
<li><code>1 &lt;= multiplier &lt;= 5</code></li>
</ul>

<!-- description:end -->

## Solutions

<!-- solution:start -->

### Solution 1

<!-- tabs:start -->

#### Python3

```python

```

#### Java

```java

```

#### C++

```cpp

```

#### Go

```go

```

<!-- tabs:end -->

<!-- solution:end -->

<!-- problem:end -->
Loading
Loading