Giter Site home page Giter Site logo

dsa-week1-code-challenge's Introduction

DSA-week1-code-challenge

Data Structures and Algorithms

This repository contains three Python functions that demonstrate the use of different data structures:

  1. Stacks:

    • Function: is_balanced(expression)
    • Description: Checks if a given expression containing parentheses, curly braces, and square brackets is balanced. An expression is considered balanced if each opening bracket has a corresponding closing bracket in the correct order.
    • Sample Usage:
      expression1 = "([]{})"
      expression2 = "([)]"
      print(is_balanced(expression1))  # Output: True
      print(is_balanced(expression2))  # Output: False
  2. Sequences (Lists/Tuples):

    • Function: remove_duplicates(sequence)
    • Description: Removes duplicates from a given sequence (list or tuple) while preserving the original order of elements.
    • Sample Usage:
      input_sequence = [2, 3, 2, 4, 5, 3, 6, 7, 5]
      result = remove_duplicates(input_sequence)
      print(result)  # Output: [2, 3, 4, 5, 6, 7]
  3. Dictionaries:

    • Function: word_frequency(sentence)
    • Description: Calculates the frequency of each word in a given sentence, ignoring punctuation and considering words in a case-insensitive manner.
    • Sample Usage:
      sentence = "This is a test sentence. This sentence is a test."
      result = word_frequency(sentence)
      print(result)

Feel free to use these functions in your Python projects by importing them and following the provided sample usage. These functions can help you solve various common problems related to data structures and algorithms.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.