Categories

## LeetCode 844. Backspace String Compare (Java)

Given two strings S and T, return if they are equal when both are typed into empty text editors. #means a backspace character.

Categories

## LeetCode 341. Flatten Nested List Iterator (Java)

Given a nested list of integers, implement an iterator to flatten it.

Each element is either an integer, or a list — whose elements may also be integers or other lists.

Categories

## LeetCode 232. Implement Queue using Stacks (Java)

Implement the following operations of a queue using stacks.

• push(x) — Push element x to the back of queue.
• pop() — Removes the element from in front of queue.
• peek() — Get the front element.
• empty() — Return whether the queue is empty.
Categories

## LeetCode 225. Implement Stack using Queues (Java)

Implement the following operations of a stack using queues.

• push(x) — Push element x onto stack.
• pop() — Removes the element on top of the stack.
• top() — Get the top element.
• empty() — Return whether the stack is empty.
Categories

## LeetCode 155. Min Stack (Java)

Source Url: https://leetcode-cn.com/problems/min-stack/

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.
Categories

## LeetCode 71. Simplify Path (Java)

Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path.

In a UNIX-style file system, a period . refers to the current directory. Furthermore, a double period .. moves the directory up a level. For more information, see: Absolute path vs relative path in Linux/Unix

Note that the returned canonical path must always begin with a slash /, and there must be only a single slash / between two directory names. The last directory name (if it exists) must not end with a trailing /. Also, the canonical path must be the shortest string representing the absolute path.

Categories

## LeetCode 20. Valid Parentheses[stack] Java

Given a string containing just the characters '('')''{''}''['and ']', determine if the input string is valid.

An input string is valid if:

1. Open brackets must be closed by the same type of brackets.
2. Open brackets must be closed in the correct order.

Note that an empty string is also considered valid.