Posts

DSA Easy Notes (C#)

DSA Easy Notes (C#) 🚀 DSA Easy Notes (C#) 1. Reverse String Input: "hello" Output: "olleh" Explanation: We reverse characters order. string str = "hello"; char[] arr = str.ToCharArray(); Array.Reverse(arr); Console.WriteLine(new string(arr)); Difference: Original: h e l l o Reversed: o l l e h 2. Palindrome Input: "madam" Output: Palindrome Explanation: Same forward & backward. string str = "madam"; string rev = new string(str.Reverse().ToArray()); Console.WriteLine(str == rev ? "Palindrome" : "Not"); Difference: Forward: madam Backward: madam → Same ✔ 3. Max in Array Input: [1,5,3,9,2] Output: 9 Explanation: Compare all values and keep largest. int[] arr = {1,5,3,9,2}; int max = arr[0]; foreach(int i in arr) { if(i > max) max = i; } Console.WriteLine(max); Difference: Compare: 1→5→9 → Max found = 9 4. Fibonacci Inpu...

DSA Questions in C#

DSA Questions in C# 🚀 DSA Questions with Explanation (C#) 1. Reverse a String Question: Reverse a given string. We convert string to array, reverse it, and convert back to string. string str = "hello"; char[] arr = str.ToCharArray(); Array.Reverse(arr); Console.WriteLine(new string(arr)); Output: olleh 2. Palindrome Check Question: Check if string is same forward and backward. Reverse the string and compare with original. string str = "madam"; string rev = new string(str.Reverse().ToArray()); Console.WriteLine(str == rev ? "Palindrome" : "Not"); Output: Palindrome 3. Maximum in Array Question: Find largest element. Loop through array and track maximum value. int[] arr = {1,5,3,9,2}; int max = arr[0]; foreach(int i in arr) { if(i > max) max = i; } Console.WriteLine(max); Output: 9 4. Fibonacci Series Question: Print Fibonacci numbers. Each number is sum of previou...

10. Sliding Window

Top 10 DSA Questions in C# 🚀 Top 10 DSA Questions in C# With Output 1. Reverse String Input: "hello" Output: "olleh" Output: olleh 2. Palindrome Input: "madam" Output: Palindrome 3. Max in Array Input: [1,5,3,9,2] Output: 9 4. Fibonacci n = 5 Output: 0 1 1 2 3 5. Two Sum nums = [2,7,11,15], target = 9 Output: index 0,1 6. Remove Duplicates Input: [1,2,2,3] Output: 1 2 3 7. Missing Number Input: [1,2,4,5] Output: 3 8. Binary Search Target = 4 Output: Found 9. Valid Parentheses Input: "()[]{}" Output: Valid 10. Sliding Window Input: [2,1,5,1,3,2], k=3 Output: 9 Created by Koustubh Javheri Keep Coding 🚀

Top 10 DSA Questions in C#

Top 10 DSA Questions in C# 🚀 Top 10 DSA Questions in C# For Interviews & Practice 1. Reverse a String string str = "hello"; char[] arr = str.ToCharArray(); Array.Reverse(arr); Console.WriteLine(new string(arr)); 2. Palindrome Check string str = "madam"; string rev = new string(str.Reverse().ToArray()); Console.WriteLine(str == rev ? "Palindrome" : "Not"); 3. Maximum in Array int[] arr = {1,5,3,9,2}; int max = arr[0]; foreach(int i in arr) { if(i > max) max = i; } Console.WriteLine(max); 4. Fibonacci Series int a = 0, b = 1; for(int i = 0; i 5. Two Sum int[] nums = {2,7,11,15}; int target = 9; Dictionary<int,int> map = new Dictionary<int,int>(); for(int i=0;i<nums.Length;i++) { int diff = target - nums[i]; if(map.ContainsKey(diff)) Console.WriteLine(map[diff] + "," + i); map[nums[i]] = i; } 6. Remove Duplicates int[] arr = {1...