Skip to main content

This module is for Gemini Api Intraction, TwoSum operations and subsequence checks

Project description

TwoSum Library

A simple Python library to find indices of numbers that sum up to a target in sorted arrays and check for subsequences.

Functions

1. twoSumK(numbers: List[int], target: int) -> List[int]

Description:
This function takes a sorted list of integers and a target integer. It returns the 1-based indices of the two numbers that add up to the target.

Parameters:

  • numbers (List[int]): A sorted list of integers.
  • target (int): The target sum.

Returns:

  • List[int]: A list containing the 1-based indices of the two numbers that sum to the target. Returns an empty list if no such numbers exist.

Example:

result = twoSumK([2, 7, 11, 15], 9)  # Output: [1, 2]

2. twoSum(numbers: List[int], target: int) -> List[int]

Description:
This function operates similarly to twoSumK, but it returns 0-based indices.

Parameters:

  • numbers (List[int]): A sorted list of integers.
  • target (int): The target sum.

Returns:

  • List[int]: A list containing the 0-based indices of the two numbers that sum to the target. Returns an empty list if no such numbers exist.

Example:

result = twoSum([2, 7, 11, 15], 9)  # Output: [0, 1]

3. is_subsequence(s: str, t: str) -> bool

Description:
This function checks if string s is a subsequence of string t.

Parameters:

  • s (str): The string to check as a subsequence.
  • t (str): The string in which to check for the subsequence.

Returns:

  • bool: Returns True if s is a subsequence of t, otherwise False.

Example:

result = is_subsequence("abc", "ahbgdc")  # Output: True

Installation

To use this library, you can clone the repository or install it via pip (if published):

pip install your_library_name

Usage

Import the functions into your script as follows:

from your_library_name import twoSumK, twoSum, is_subsequence

# Example usage
indices = twoSumK([2, 3, 4], 6)
print(indices)  # Output: [1, 3]

License

This project is licensed under the MIT License - see the LICENSE file for details.


Feel free to modify any sections to better fit your library or personal style!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tamilan-0.1.5.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tamilan-0.1.5-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file tamilan-0.1.5.tar.gz.

File metadata

  • Download URL: tamilan-0.1.5.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for tamilan-0.1.5.tar.gz
Algorithm Hash digest
SHA256 f7a8d2185cb6f381b0f0c5a36223063141a402258b6df635a6c4b46e16ad8c41
MD5 481b5303a68fd76333249f80a1e53293
BLAKE2b-256 fb5e6f658a303e992e31a36d13e6bf380a77876a6873d619685568f2bf257987

See more details on using hashes here.

File details

Details for the file tamilan-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: tamilan-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for tamilan-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 fbb92818d2c46b6d504ff3431a38cf7698267da24d7acb3919431bb72c56713d
MD5 aeb25d3849a1627525063ce9fbc8f477
BLAKE2b-256 c593b09e61797a4bb67a27bc47582c113f5529684ce545588d09dff1d2b7c17f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page