Skip to content

PLPAfrica/Python-Hack1---May-Cohort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

Data Structures and Algorithms Practice

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.

Questions

1. Reverse a String Using a Stack

  • Task: Implement a stack data structure to reverse a string.
  • Function: reverse_string(s: str) -> str
  • Example:
    • Input: "hello"
    • Output: "olleh"

2. Implement a Queue Using Two Stacks

  • 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
    

3. Find the Maximum Element in a List Using a Linked List

  • 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
    

Submission Instructions

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

Submission form

https://forms.gle/VUTFyWTXKUPq4CMQA

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published