- Same Substring
Two strings, s and t, each of length n, that contain lowercase English characters are given as well as an integer K.
- The cost to change the iᵗʰ character in s from sᵢ to tᵢ is the absolute difference of the ASCII value of characters, i.e., abs(sᵢ - tᵢ).
Find the maximum length of a substring of s from to t, that can be changed to the corresponding substring of t with a total cost less than or equal to K. If there is no such substring, return 0.
Example
It is given that s = "adpgkr", t = "cdmxki", K = 6.
- Change s₀ from 'a' to 'c' with cost = abs('a' - 'c') = 2.
String is now "cdpgkr" and K = 6 - 2 = 4. - Change s₂ from 'p' to 'm' with cost = abs('p' - 'm') = 3.
String is "cdmgkr" and K = 4 - 3 = 1. - The only character left to change is 'g' to 'x', which costs more than K.
Constraints
- String s consists of lowercase English alphabetic letters only, ascii[a-z].
- 1 ≤ the length of s ≤ 10⁵.
- There will always be two non-overlapping programmer strings.
Input Format for Custom Testing
Input from stdin will be processed as follows and passed to the function:
The only line contains a string, s.
Sample Case 0
Sample Input
programmerxprogrammer
Sample Output
2
Explanation
p r o g r a m m e r x p r o g r a m m e r
- Predicting the S&P 500 Index
The S&P 500 index is an American stock market index based on the market capitalizations of 500 large companies that have common stock listed on the NYSE or NASDAQ. Build a model using the prices of 500 stocks and the value of the S&P 500 index. This data is collected 4000 times per minute, Monday through Friday, from 9:30 AM to 4 PM New York time. The model then predicts the S&P index for the next 1000 minutes given the prices of all 500 stocks.
Dataset
You are provided the training dataset in the form of a CSV file, train.csv.
- The file contains exactly 4000 rows and each row contains 501 comma-separated values.
- The first 500 columns represent the stock prices, and the last is the S&P 500 index.
You are also provided a test dataset in the form of a CSV file, test.csv, that contains exactly 1000 rows.
- Each row contains exactly 500 comma-separated values that describe the stock prices.
Submission Details
Write the code to build the model and predict the S&P index in the editor below.
- The code must save the predictions in the file prediction.csv, which contains exactly 1000 rows. Each row contains the value of S&P index that corresponds to the stock prices provided in the test.csv.
- Note that both the files are provided in the current working directory.
- Use the read-csv techniques in your preferred language and then train the model to predict the S&P index for the stock prices provided in the test.csv file.
- The final csv should not have a header.
我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.
