mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-06 23:28:29 +08:00
更新 059.螺旋矩阵II 排版格式修复
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
## 算法公开课
|
||||
|
||||
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[拿下螺旋矩阵!LeetCode:59.螺旋矩阵II](https://www.bilibili.com/video/BV1SL4y1N7mV),相信结合视频再看本篇题解,更有助于大家对本题的理解**。
|
||||
|
||||
|
||||
## 思路
|
||||
|
||||
这道题目可以说在面试中出现频率较高的题目,**本题并不涉及到什么算法,就是模拟过程,但却十分考察对代码的掌控能力。**
|
||||
@ -125,15 +125,15 @@ public:
|
||||
|
||||
## 类似题目
|
||||
|
||||
* 54.螺旋矩阵
|
||||
* 剑指Offer 29.顺时针打印矩阵
|
||||
* [54.螺旋矩阵](https://leetcode.cn/problems/spiral-matrix/)
|
||||
* [剑指Offer 29.顺时针打印矩阵](https://leetcode.cn/problems/shun-shi-zhen-da-yin-ju-zhen-lcof/)
|
||||
|
||||
|
||||
|
||||
|
||||
## 其他语言版本
|
||||
|
||||
Java:
|
||||
### Java:
|
||||
|
||||
```Java
|
||||
class Solution {
|
||||
@ -176,7 +176,7 @@ class Solution {
|
||||
}
|
||||
```
|
||||
|
||||
python3:
|
||||
### python3:
|
||||
|
||||
```python
|
||||
class Solution:
|
||||
@ -207,7 +207,7 @@ class Solution:
|
||||
return nums
|
||||
```
|
||||
|
||||
javaScript
|
||||
### JavaScript:
|
||||
|
||||
```javascript
|
||||
|
||||
@ -259,7 +259,7 @@ var generateMatrix = function(n) {
|
||||
|
||||
```
|
||||
|
||||
TypeScript:
|
||||
### TypeScript:
|
||||
|
||||
```typescript
|
||||
function generateMatrix(n: number): number[][] {
|
||||
@ -304,7 +304,7 @@ function generateMatrix(n: number): number[][] {
|
||||
};
|
||||
```
|
||||
|
||||
Go:
|
||||
### Go:
|
||||
|
||||
```go
|
||||
package main
|
||||
@ -397,7 +397,7 @@ func generateMatrix(n int) [][]int {
|
||||
}
|
||||
```
|
||||
|
||||
Swift:
|
||||
### Swift:
|
||||
|
||||
```swift
|
||||
func generateMatrix(_ n: Int) -> [[Int]] {
|
||||
@ -453,7 +453,7 @@ func generateMatrix(_ n: Int) -> [[Int]] {
|
||||
}
|
||||
```
|
||||
|
||||
Rust:
|
||||
### Rust:
|
||||
|
||||
```rust
|
||||
impl Solution {
|
||||
@ -506,7 +506,8 @@ impl Solution {
|
||||
}
|
||||
```
|
||||
|
||||
PHP:
|
||||
### PHP:
|
||||
|
||||
```php
|
||||
class Solution {
|
||||
/**
|
||||
@ -548,7 +549,8 @@ class Solution {
|
||||
}
|
||||
```
|
||||
|
||||
C:
|
||||
### C:
|
||||
|
||||
```c
|
||||
int** generateMatrix(int n, int* returnSize, int** returnColumnSizes){
|
||||
//初始化返回的结果数组的大小
|
||||
@ -607,7 +609,8 @@ int** generateMatrix(int n, int* returnSize, int** returnColumnSizes){
|
||||
return ans;
|
||||
}
|
||||
```
|
||||
Scala:
|
||||
### Scala:
|
||||
|
||||
```scala
|
||||
object Solution {
|
||||
def generateMatrix(n: Int): Array[Array[Int]] = {
|
||||
@ -659,7 +662,8 @@ object Solution {
|
||||
}
|
||||
}
|
||||
```
|
||||
C#:
|
||||
### C#:
|
||||
|
||||
```csharp
|
||||
public class Solution {
|
||||
public int[][] GenerateMatrix(int n) {
|
||||
@ -688,3 +692,4 @@ public class Solution {
|
||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
||||
</a>
|
||||
|
||||
|
Reference in New Issue
Block a user