Lunski's Clutter

This is a place to put my clutters, no matter you like it or not, welcome here.

0%

Given the root of a binary tree, return the inorder traversal of its nodes’ values.

Example 1:

1
2
Input: root = [1,null,2,3]
Output: [1,3,2]

Example 2:

1
2
Input: root = []
Output: []

Example 3:

1
2
Input: root = [1]
Output: [1]

Example 4:

1
2
Input: root = [1,2]
Output: [2,1]

Example 5:

1
2
Input: root = [1,null,2]
Output: [1,2]
Read more »

在吃飯聽到這首歌,很喜歡主唱細膩的聲線,MV在說男女遇到災難時的反應,但我想是在說更普羅大眾的-當感情遇到考驗時你還會選擇繼續相信對方嗎?

Read more »

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.

push(x) – Push element x onto stack.
pop() – Removes the element on top of the stack.
top() – Get the top element.
getMin() – Retrieve the minimum element in the stack.

Example 1:

1
2
3
4
5
6
Input
["MinStack","push","push","push","getMin","pop","top","getMin"]
[[],[-2],[0],[-3],[],[],[],[]]

Output
[null,null,null,null,-3,null,0,-2]

Explanation

1
2
3
4
5
6
7
8
MinStack minStack = new MinStack();
minStack.push(-2);
minStack.push(0);
minStack.push(-3);
minStack.getMin(); // return -3
minStack.pop();
minStack.top(); // return 0
minStack.getMin(); // return -2
Read more »

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.

You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity.

Example 1:

1
2
Input: 1->2->3->4->5->NULL
Output: 1->3->5->2->4->NULL

Example 2:

1
2
Input: 2->1->3->5->6->4->7->NULL
Output: 2->3->6->7->1->5->4->NULL
Read more »

經過這麼久的努力leetcode初級基礎題目我們已經走過一輪了,但我們一直沒進一步認識資料結構與演算法,我想在這暫停一下,先來理解基礎結構,之後的題目會比較好上手。

Read more »