DSA challenges
Practice problem statements with input format, output format, constraints and solutions.
DSA Introduction challenge
Build a small solution that uses DSA Introduction in DSA and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core dsa introduction pattern before polishing the final output.
Solution
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Time Complexity challenge
Build a small solution that uses Time Complexity in DSA and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core time complexity pattern before polishing the final output.
Solution
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Space Complexity challenge
Build a small solution that uses Space Complexity in DSA and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core space complexity pattern before polishing the final output.
Solution
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Arrays challenge
Build a small solution that uses Arrays in DSA and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core arrays pattern before polishing the final output.
Solution
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Strings challenge
Build a small solution that uses Strings in DSA and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core strings pattern before polishing the final output.
Solution
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Objects and Hash Maps challenge
Build a small solution that uses Objects and Hash Maps in DSA and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core objects and hash maps pattern before polishing the final output.
Solution
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Recursion challenge
Build a small solution that uses Recursion in DSA and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core recursion pattern before polishing the final output.
Solution
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Sorting challenge
Build a small solution that uses Sorting in DSA and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core sorting pattern before polishing the final output.
Solution
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Searching challenge
Build a small solution that uses Searching in DSA and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core searching pattern before polishing the final output.
Solution
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Stack challenge
Build a small solution that uses Stack in DSA and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core stack pattern before polishing the final output.
Solution
function uniqueValues(values) {
const seen = new Set();
return values.filter((value) => {
if (seen.has(value)) return false;
seen.add(value);
return true;
});
}