You are given several LeetCode-style coding tasks. Implement each with the stated time/space goals and handle edge cases.
Input: a string s (ASCII or lowercase letters).
Output: an integer: the maximum length of a contiguous substring of s that contains no repeated characters.
Constraints: target time O(n).
Input: an integer k and an array of points points, where each point is (x, y).
Output: any ordering of the k points with smallest squared distance to the origin, x^2 + y^2.
Constraints: must be O(n log k) time (and O(k) extra space besides output).
Input: an array of positive integers values (can reuse each value unlimited times) and an integer amount.
Output: the minimum number of values needed to sum to amount; return -1 if impossible.
Constraints: explain state definition and initialization clearly; typical target O(len(values) * amount) time.
Input: strings s and p.
Output: all starting indices i such that s[i : i+len(p)] is a permutation of p.
Constraints: target O(|s|) time using a fixed-size window and character counts.
Input: an integer array a.
Output: the lexicographically largest array that is strictly smaller than a and can be obtained by at most one swap of two indices. If no such array exists, return a unchanged.
Constraints: in-place, O(n) or O(n log n); clearly discuss corner cases (duplicates, already smallest permutation, repeated values near the pivot).