10 views
23 Jan 2026
Arrange elements such that arr[0] >= arr[1] = arr[3]... This teaches pattern-based sorting and swapping logic.
Logic: Swap adjacent elements at odd positions if needed
...
7 views
23 Jan 2026
Find length of longest sequence of consecutive numbers that can be formed from array elements. This teaches set-based thinking.
Logic: For each number, check if it's start of sequence, then count l...
8 views
23 Jan 2026
Find three numbers in array whose sum equals target value.This develops nested loop optimization and multiple variable tracking.
Logic: Use three nested loops to check all possible combinations
...
7 views
23 Jan 2026
Shift all zero elements to the end while maintaining order of non-zero elements. This teaches two-pointer technique.
Logic: Use index to place non-zero elements, fill rest with zeros...
7 views
23 Jan 2026
Find index where sum of elements before it equals sum after it. This teaches prefix sum concept and optimization.
Logic: Calculate total sum, then track left sum while traversing
...
6 views
23 Jan 2026
Identify and display all prime numbers present in given array. This combines prime checking logic with array traversal.
Logic: For each number, check if it's prime using division method
...
7 views
23 Jan 2026
Rearrange array so all even numbers come before odd numbers. This teaches array partitioning logic.
Logic: Create two arrays for even/odd, then merge back...
6 views
23 Jan 2026
Count how many times each unique element appears in array. This develops nested loop logic and counting techniques.
Logic: For each element, count its occurrences in entire array
...
6 views
23 Jan 2026
Remove an element at a specific index and shift remaining
elements left. This teaches array manipulation and size management.
Logic: Shift all elements after deletion point one position left
...
6 views
23 Jan 2026
Write a program to insert a new element at a given position in
an array. This requires shifting elements to make space.
Logic: Shift elements right from insertion point, then insert new element...
6 views
23 Jan 2026
Search for a specific element and return its position (index). If not found, return -1. This teaches linear search concept.
Logic: Compare each element with search value
...
7 views
23 Jan 2026
Given an array with positive and negative numbers, count how many are positive and how many are negative. This builds conditional logic skills.
Logic: Check each number's sign and increment respectiv...
5 views
23 Jan 2026
Description: Write code to copy all elements from one array to another array. This demonstrates basic array manipulation and memory concepts.
Logic: Iterate through source array and assign to destina...
8 views
23 Jan 2026
Description: Create a program to find the smallest number in an array. This teaches comparison logic and how to track minimum values.
Logic: Assume first element is minimum, then compare with rest
...
8 views
23 Jan 2026
Write a program that takes an array of numbers and calculates their average. This helps understand array traversal and basic arithmetic operations.
Logic: Sum all elements and divide by total count...