Most frequently asked questions on Collections (15mins programming)
---
### *1. Palindrome Check*
> Write a program to check if a given string is a palindrome.
> (Classic! You already did this one.)
---
### *2. Anagram Check*
> Given two strings, check if they are anagrams (contain the same characters in any order).
csharp
"listen" → "silent" ✅
"hello" → "world" ❌
---
### *3. Find Duplicate Words in a List*
> Given a list of strings, find all duplicates and their counts using LINQ.
csharp
["cat","dog","cat","apple","dog"]
// Output: cat=2, dog=2
---
### **4. Reverse a String Without Using Reverse()**
> Write code to reverse a string manually (loop or recursion).
---
### *5. Find Second Largest Number in an Array*
> Input: [10, 4, 6, 8, 15] → Output: 10
---
### *6. Count Vowels in a String*
> Count how many vowels appear in "programming".
> *(Can be done with Where + Count in LINQ.)*
---
### *7. Remove Duplicates from a List*
> Input: [1, 2, 2, 3, 4, 4, 5] → Output: [1, 2, 3, 4, 5]
---
### *8. Find First Non-Repeating Character*
> In a string "swiss", return the first non-repeating character → "w".
---
### *9. Word Frequency Counter*
> Given a sentence, count how many times each word appears.
> *(Like "This is a test. This test is simple." → \`"This=2, is=2, test=2, simple=1"*)
---
### *10. Check if a String Has All Unique Characters*
> "abcdef" → true, "apple" → false.
---
### *11. Rotate an Array by k Positions*
> Input: [1,2,3,4,5], k=2 → Output: [4,5,1,2,3].
---
### *12. Merge Two Sorted Arrays*
> Input: [1,3,5] and [2,4,6] → Output: [1,2,3,4,5,6].
---
### *13. Find Most Frequent Character*
> "mississippi" → 'i' with count = 4.
---
### *1. Palindrome Check*
> Write a program to check if a given string is a palindrome.
> (Classic! You already did this one.)
---
### *2. Anagram Check*
> Given two strings, check if they are anagrams (contain the same characters in any order).
csharp
"listen" → "silent" ✅
"hello" → "world" ❌
---
### *3. Find Duplicate Words in a List*
> Given a list of strings, find all duplicates and their counts using LINQ.
csharp
["cat","dog","cat","apple","dog"]
// Output: cat=2, dog=2
---
### **4. Reverse a String Without Using Reverse()**
> Write code to reverse a string manually (loop or recursion).
---
### *5. Find Second Largest Number in an Array*
> Input: [10, 4, 6, 8, 15] → Output: 10
---
### *6. Count Vowels in a String*
> Count how many vowels appear in "programming".
> *(Can be done with Where + Count in LINQ.)*
---
### *7. Remove Duplicates from a List*
> Input: [1, 2, 2, 3, 4, 4, 5] → Output: [1, 2, 3, 4, 5]
---
### *8. Find First Non-Repeating Character*
> In a string "swiss", return the first non-repeating character → "w".
---
### *9. Word Frequency Counter*
> Given a sentence, count how many times each word appears.
> *(Like "This is a test. This test is simple." → \`"This=2, is=2, test=2, simple=1"*)
---
### *10. Check if a String Has All Unique Characters*
> "abcdef" → true, "apple" → false.
---
### *11. Rotate an Array by k Positions*
> Input: [1,2,3,4,5], k=2 → Output: [4,5,1,2,3].
---
### *12. Merge Two Sorted Arrays*
> Input: [1,3,5] and [2,4,6] → Output: [1,2,3,4,5,6].
---
### *13. Find Most Frequent Character*
> "mississippi" → 'i' with count = 4.
>> Answer: Find the character with highest frequency/Count.
---
### *14. Sum of Digits in a String*
> "a1b2c3" → 1+2+3 = 6.
---
### *15. Check if Two Strings are Rotations*
> "abcd" and "cdab" → true.
> *(Hint: double one string "abcdabcd", then check if other is substring.)*
No comments:
Post a Comment