Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

← Back to Python Study Repository

Python Code Problems for Interview

This folder contains Python code problems that are commonly asked during technical interviews. The problems are designed to help you practice and strengthen your Python programming skills.

Table of Contents

Features

  • Variety of Problems: Covers a range of problem types, including algorithmic challenges, data structure manipulations, and coding puzzles.
  • Structured Solutions: Each problem includes a well-documented solution to help you understand the approach and logic.
  • Modular Code: The code is written modularly, making it easier to read, run, and reuse.

Problem Descriptions

From code_problem.py

  • Reverse String: Reverses a given string.
  • Check Palindrome: Checks if a given string is a palindrome.
  • Find Duplicates: Finds duplicate elements in a list.
  • Generate Fibonacci Numbers: Generates the first n Fibonacci numbers.
  • Calculate Factorial: Calculates the factorial of a number.
  • Check Anagram: Checks if two strings are anagrams.
  • Merge Sorted Arrays: Merges two sorted arrays into one.
  • Find Missing Number: Finds the missing number in a list of integers.
  • Maximum Subarray Sum: Finds the maximum sum of a contiguous subarray.
  • Count Vowels: Counts the number of vowels in a string.
  • Binary Search: Performs binary search to find a target in a sorted array.
  • Check Prime Number: Checks if a number is prime.
  • Rotate Matrix: Rotates a matrix 90 degrees clockwise.
  • Longest Common Prefix: Finds the longest common prefix among a list of strings.
  • Validate Parentheses: Validates if a string contains valid parentheses.

From search.py

  • Binary Search: Performs binary search on a sorted array.
  • Breadth-First Search (BFS): Searches for a node in a graph using BFS.
  • Depth-First Search (DFS): Searches for a node in a graph using DFS.
  • Binary Tree Search: Searches for a value in a binary search tree.

From sorting.py

  • Bubble Sort: Sorts a list using the Bubble Sort algorithm.
  • Insertion Sort: Sorts a list using the Insertion Sort algorithm.
  • Merge Sort: Sorts a list using the Merge Sort algorithm.
  • Quick Sort: Sorts a list using the Quick Sort algorithm.
  • Binary Sort: Sorts a list using the Binary Sort algorithm (uses a Binary Search Tree).

From water_level_heights_bfs.py

  • Assign Heights to Land and Water Cells: Assigns heights to cells in a matrix following specific rules, ensuring the maximum height is maximized while satisfying constraints.

How to Use

  1. Clone the repository:
    git clone https://github.com/smaruf/python-study.git

  2. Navigate to the code-run folder:
    cd python-study/src/code-run

  3. Run the Python scripts:
    python example_problem.py

    Example:
    python fibonacci.py

  4. Explore the solutions to understand different approaches.

Prerequisites

  • Python: Ensure you have Python 3.x installed on your system. You can download it from python.org.
  • Dependencies: Install any required libraries using:
    pip install -r requirements.txt

Contributing

Contributions are welcome! If you have any new problems or more optimized solutions, feel free to submit a pull request.

Guidelines for Contributions:

  • Add detailed comments and explanations for new problems or solutions.
  • Ensure the code follows PEP 8 standards.
  • Update the requirements.txt file if new dependencies are introduced.

License

This project is licensed under the MIT License. For more details, see LICENSE.

FAQ

How can I report an issue?

If you encounter any issues, please open an issue in the GitHub repository.

Can I add problems in other programming languages?

Currently, this folder focuses on Python problems. Contributions in other programming languages can be added to respective folders in the repository.

Where can I find more resources for Python programming?

Check out the official Python documentation and other online platforms like LeetCode and HackerRank.


Would you like me to assist in committing this updated README file to your repository?