LESSON 49 / 75·2 min readFoundation

Arrays and strings in C#

Should knowConcept lesson
01 Understand02 Recall03 Prepare

Problems to practice

  • Two Sum
  • Best Time to Buy and Sell Stock
  • Move Zeroes
  • Product of Array Except Self
  • Valid Palindrome
  • Longest Substring Without Repeating Characters
  • Group Anagrams

Example: two sum

csharp
public int[] TwoSum(int[] nums, int target) {
    var map = new Dictionary<int, int>();

    for (int i = 0; i < nums.Length; i++) {
        int needed = target - nums[i];
        if (map.ContainsKey(needed)) {
            return new[] { map[needed], i };
        }
        map[nums[i]] = i;
    }

    return Array.Empty<int>();
}

Time and space complexity

  • Time: O(n)
  • Space: O(n)

PAUSE & RECALL

Can you explain it without the notes?

Arrays and strings in C#

Use your own words. Explain an example and one limitation before checking the explanation.

Check your explanation

Common questions

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: Hashing in .NET

Adapted from 17_DSA_DOTNET.md · “2. Arrays and strings in C#”. Examples are study fragments; framework behavior can depend on your version.