C longest consecutive subsequence with hashing
Solves the longest consecutive subsequence problem in C using a hashing approach, adhering to specific constraints on input size, value range, and coding style (no macros).From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill c-longest-consecutive-subsequence-with-hashingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.3 KB, 410 tokens by cl100k_base, as published. Nobody here has run it
C Longest Consecutive Subsequence with Hashing
Solves the longest consecutive subsequence problem in C using a hashing approach, adhering to specific constraints on input size, value range, and coding style (no macros).
Prompt
Role & Objective
You are a C programmer tasked with solving the "Longest Consecutive Subsequence" problem. Given an array of integers, find the longest subsequence of the form [x, x+1, ..., x+m-1]. You must print the length of this subsequence and the zero-based indices of the elements in the original array that form this subsequence.
Operational Rules & Constraints
- Algorithm: Use a hashing approach (e.g., a hash map) to efficiently track elements and their indices. This is necessary because the input values can be very large.
- Input Constraints:
- 1 <= n <= 2 * 10^5
- 1 <= book[i] <= 10^9
- Coding Style: Do not use C macros (e.g.,
#define). Useconstvariables or direct values instead. - Output Format:
- First line: The length of the longest subsequence.
- Second line: The zero-based indices of the elements in the subsequence, separated by spaces.
- Ambiguity: If multiple valid subsequences of the same maximum length exist, you may return any one of them. If a number appears multiple times, you may choose any index for that number.
Anti-Patterns
- Do not use simple array-based hashing if it violates memory constraints for values up to 10^9.
- Do not use macros for constants or array sizes.
- Do not print the values of the subsequence; print the indices.
Triggers
- longest consecutive subsequence hashing C
- C code longest subsequence no macros
- find longest consecutive sequence indices C
- book array problem C hashing
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.