_99-problems-rust-lists

Table of Contents

Problems Rust Lists

List Problems

1. Write a function last : 'a list -> 'a option that returns the last element of a list.

{{# include _include/code/algorithms/99-problems/rust/src/lists/last_element.rs }}

2. Find the last but one (last and penultimate) elements of a list.

{{# include _include/code/algorithms/99-problems/rust/src/lists/last_two.rs }}

3. Find the kth element of a list.

{{# include _include/code/algorithms/99-problems/rust/src/lists/kth_element.rs }}

4. Find the number of elements of a list.

{{# include _include/code/algorithms/99-problems/rust/src/lists/size.rs }}

5. Reverse a list.

{{# include _include/code/algorithms/99-problems/rust/src/lists/reverse.rs }}

6. Find out whether a list is a palindrome.

{{# include _include/code/algorithms/99-problems/rust/src/lists/palindrome.rs }}

7. Flatten a nested list structure.

{{# include _include/code/algorithms/99-problems/rust/src/lists/flatten.rs }}

8. Eliminate consecutive duplicates of list elements.

{{# include _include/code/algorithms/99-problems/rust/src/lists/duplicate.rs }}

9. Pack consecutive duplicates of list elements into sublists.

{{# include _include/code/algorithms/99-problems/rust/src/lists/pack_consecutive_duplicates.rs }}