Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Java program Get_Equal_Substring_Within_Budget #455

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ganesh-159th
Copy link

Program Description: Get Equal Substring Within Budget
The "Get Equal Substring Within Budget" program is designed to calculate the maximum length of a substring of two given strings, s and t, that can be changed to match each other within a specified cost limit (maxCost). The cost of changing a character from one string to another is determined by the absolute difference between their ASCII values.

Functionality:
The program takes three inputs:
The first string s.
The second string t.
The maximum cost maxCost.
It iterates through the characters of both strings simultaneously and calculates the cost of changing each character from s to t.
It maintains a sliding window approach to find the maximum length of a substring that can be changed within the specified cost limit.
The program then returns the maximum length of the valid substring.

**// Sample input
String s = "abcd";
String t = "bcdf";
int maxCost = 3;

// Output
int maxLength = obj.equalSubstring(s, t, maxCost);
System.out.println("Maximum length of valid substring: " + maxLength);
**

Expected Output:
Maximum length of valid substring: 3

Copy link

vercel bot commented May 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
open-source-contribution-for-beginners ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2024 5:09pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant