mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-11 04:54:51 +08:00
@ -38,7 +38,7 @@ queue.empty(); // 返回 false
|
|||||||
|
|
||||||
## 思路
|
## 思路
|
||||||
|
|
||||||
《代码随想录》算法公开课:[栈的基本操作! | LeetCode:232.用栈实现队列](https://www.bilibili.com/video/BV1nY4y1w7VC),相信结合视频再看本篇题解,更有助于大家对链表的理解。
|
《代码随想录》算法公开课:[栈的基本操作! | LeetCode:232.用栈实现队列](https://www.bilibili.com/video/BV1nY4y1w7VC),相信结合视频再看本篇题解,更有助于大家对栈和队列的理解。
|
||||||
|
|
||||||
|
|
||||||
这是一道模拟题,不涉及到具体算法,考察的就是对栈和队列的掌握程度。
|
这是一道模拟题,不涉及到具体算法,考察的就是对栈和队列的掌握程度。
|
||||||
@ -662,3 +662,4 @@ impl MyQueue {
|
|||||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||||
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
@ -137,8 +137,18 @@ class Solution {
|
|||||||
resSet.add(i);
|
resSet.add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//将结果几何转为数组
|
|
||||||
|
//方法1:直接将结果几何转为数组
|
||||||
return resSet.stream().mapToInt(x -> x).toArray();
|
return resSet.stream().mapToInt(x -> x).toArray();
|
||||||
|
|
||||||
|
//方法2:另外申请一个数组存放setRes中的元素,最后返回数组
|
||||||
|
int[] arr = new int[setRes.size()];
|
||||||
|
int j = 0;
|
||||||
|
for(int i : setRes){
|
||||||
|
arr[j++] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return arr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -423,3 +433,4 @@ C#:
|
|||||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||||
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user