Skip to content
ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

121 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Week 1 Day 1 (16/06/2025)

1. Replace All Negative Numbers with Zero

A basic array manipulation problem that introduces conditional element modification.

Given an array nums of size n, replace all negative numbers in the array with zero. Return the modified array.

This problem introduces you to array traversal and conditional modification of elements, which are fundamental skills in array manipulation and data processing.

Your task: Replace all negative numbers in the array with zero and return the modified array.

Examples

Input:

nums = [-1, 2, -3, 4, 5]

Output:

[0, 2, 0, 4, 5]

Input:

nums = [0, -5, -10]

Output:

[0, 0, 0]

Input:

nums = [1, 2, 3, 4]

Output:

[1, 2, 3, 4]

2. Missing and Repeated

A problem that requires finding a missing number and a duplicate number in an array.

Given an unsorted array of size n. Array elements are in the range of 1 to n. One number from set {1, 2, ...n} is missing and one number occurs twice in the array. The task is to find these two numbers.

Your task: Find the missing number and the number that appears twice in the array.

Examples

Input:

[3, 1, 3]

Output:

Missing: 2, Twice: 3

Input:

[4, 3, 6, 2, 1, 1]

Output:

Missing: 5, Twice: 1

3. Sum of Array Elements

A fundamental array operation that calculates the total sum of all elements.

Given an array of integers, write a program that calculates and returns the sum of all elements in the array.

This is one of the most fundamental array operations where you need to traverse through each element and accumulate their values. This type of operation is commonly used in mathematical calculations and data analysis.

Your task: Calculate and return the sum of all elements in the array.

Examples

Input:

[1, 2, 3, 4, 5]

Output:

15

Input:

[10, 20, 30]

Output:

60

Input:

[7, 3, 9, 1, 6]

Output:

26

About

๐Ÿš€ Get ready to code, learn, and grow! UPES ACM & ACM-W Student Chapters proudly present "21DaysOfCode" โ€” a thrilling journey designed to sharpen your problem-solving skills and build an unstoppable daily coding streak. Letโ€™s turn consistency into a superpower. Are you up for the challenge? ๐Ÿ’ป๐Ÿ”ฅ

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages