Given a string s
, return a list
containing of all possible partitions of that string that are palindromes. A palindrome is a string that is the same backwards as forwards. For example, abba
is a palindrome.
The string aab
can be partitioned as follows: [['a','a','b'], ['aa','b']]
. This is because a single character is by definition a palindrome.
Given the head
of a linked list, remove all items with val
. Afterwards, return the new head.
Given an array nums
, delete all items that are equal to val
. Return the total number of remaining items and perform the deletion in place.
Traverse a tree where the root
node is given with a zig-zag level and return the values in a list
with one entry per level. For example:
Given the root
node of a binary tree, print all values in order, meaning from left to right on the same level.
To solve this, we can use the standard breadth-first-search (BFS) algorithm in an iterative fashion with a queue
. As an output we use a list
and leverage the position -1
to add the current level to the list. For every level we append one new element to the end of the list.