当前位置:网站首页>[jzof] 06 print linked list from end to end
[jzof] 06 print linked list from end to end
2022-07-24 21:05:00 【Sighed, angry】

recursive :
/** * public class ListNode { * int val; * ListNode next = null; * * ListNode(int val) { * this.val = val; * } * } * */
import java.util.ArrayList;
public class Solution {
ArrayList<Integer> res = new ArrayList<>();
public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
if(listNode !=null){
printListFromTailToHead(listNode.next);
res.add(listNode.val);
}
return res;
}
}
Non recursive :
Go through the list , The traversed value is added to the stack .
Then traverse the stack again .
边栏推荐
- Rce (no echo)
- Evolution of network IO model
- PHP page Jump mode
- Detailed explanation of ThreadLocal
- Open source demo | release of open source example of arcall applet
- Merge sort
- Mysql8 doesn't seem to support MyISAM partition tables. Does polardb-x support MyISAM partition tables?
- Opencv learning Day2
- Leetcode 1928. minimum cost of reaching the destination within the specified time
- Experience of using dump file to reverse locate crash location
猜你喜欢
![[basic data mining technology] KNN simple clustering](/img/df/f4a3d9b8a636ea968c98d705547be7.png)
[basic data mining technology] KNN simple clustering

How to prevent weight under Gao Bingfa?

One bite of Stream(7)

Rce (no echo)

Eight transformation qualities that it leaders should possess

Evolution of network IO model

Pychart tutorial: 5 very useful tips

Methods of using tyrosine modified peptide nucleic acid PNA | Tyr PNA | BZ Tyr PNA | 99Tcm survivinmrna antisense peptide nucleic acid

Upgrade appium automation framework to the latest 2.0

Mitmproxy tampering with returned data
随机推荐
[training Day10] linear [mathematics] [thinking]
Five common misuse of async/await
How do test / development programmers survive the midlife crisis? You can see it at a glance
Summary of yarn capacity scheduler
Synthesis route of ALA PNA alanine modified PNA peptide nucleic acid | AC ala PNA
How about Urumqi Shenwan Hongyuan securities account opening? Is it safe?
Transport layer protocol parsing -- UDP and TCP
Static & dynamic & file address book
Mysql8 doesn't seem to support MyISAM partition tables. Does polardb-x support MyISAM partition tables?
Can century model simulate soil respiration? Practice technology application and case analysis of century model
Two methods of how to export asynchronous data
Go language error handling
Summary of communication with customers
Use of cache in C #
Selenium is detected as a crawler. How to shield and bypass it
[basic data mining technology] KNN simple clustering
C WinForm actual operation XML code, including the demonstration of creating, saving, querying and deleting forms
[summary of Feature Engineering] explain what features are and the steps of feature engineering
怎么在中金证券购买新课理财产品?收益百分之6
C local functions and yield statements