This repository contains your solutions to three simple data structures and algorithms problems. Please follow the instructions below to complete the tasks and submit your work.
- Task: Implement a stack data structure to reverse a string.
- Function:
reverse_string(s: str) -> str
- Example:
- Input:
"hello"
- Output:
"olleh"
- Input:
- Task: Implement a queue using two stacks.
- Class:
QueueWithStacks
- Methods:
enqueue(x: int)
: Adds an element to the queue.dequeue() -> int
: Removes and returns the front element of the queue.
- Example:
q = QueueWithStacks() q.enqueue(1) q.enqueue(2) print(q.dequeue()) # Output: 1 print(q.dequeue()) # Output: 2
- Task: Implement a singly linked list and find the maximum element in the list.
- Class: LinkedList
- Method: find_max() -> int
- Example
ll = LinkedList() ll.append(3) ll.append(1) ll.append(4) ll.append(2) print(ll.find_max()) # Output: 4
- Fork this repository.
- Clone the forked repository to your local machine.
- Create a separate branch for your solutions.
- Implement the solutions to the above questions in Python.
- Commit your changes with clear and descriptive messages.
- Push your changes to your forked repository.
- Create a pull request (PR) to the original repository with your solutions.
- Submit the URL of your GitHub repository as your final submission.