Skip to content

Shubh525/21DaysOfCode-2025

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1,316 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Week 1 Day 3 (18/06/2025)

1. K-Frequency Element Sum

A problem that combines frequency counting with conditional summation of distinct elements.

Given an array of integers and an integer k, find the sum of all distinct elements that appear exactly k times in the array. Each such element should be included only once in the sum.

Your task: Find the sum of all distinct elements that appear exactly k times in the array.

Examples

Input:

nums = [2, 3, 9, 9], k = 1

Output:

5

Input:

nums = [1, 8, 8, 8, 5, 6, 2], k = 3

Output:

8

2. Check for Duplicates

A problem that introduces duplicate detection algorithms and set-based thinking.

Given an array nums of size n, return true if any value appears more than once, otherwise return false.

This problem introduces you to duplicate detection algorithms and teaches you about set-based thinking and comparison operations within arrays.

Your task: Return true if any value appears more than once, otherwise return false.

Examples

Input:

nums = [1, 2, 3, 4]

Output:

false

Input:

nums = [1, 2, 3, 2]

Output:

true

Input:

nums = [5, 5, 5]

Output:

true

3. Find the Second Largest Element

A problem that teaches about finding extremes in data and handling edge cases.

Given an array nums of size n, find the second largest unique element in the array. If it doesn't exist (e.g., all elements are the same), return -1.

This problem teaches you about finding extremes in data and handling edge cases where the desired element might not exist.

Your task: Find the second largest unique element in the array, or return -1 if it doesn't exist.

Examples

Input:

nums = [10, 20, 30, 40]

Output:

30

Input:

nums = [5, 5, 5]

Output:

-1

Input:

nums = [3, 2, 1]

Output:

2

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

No releases published

Packages

 
 
 

Contributors

Languages

  • C 40.9%
  • Java 26.3%
  • Python 18.1%
  • C++ 14.7%