šŸŽ’
Technical Interview Study Guide
  • šŸ•Welcome!
  • šŸ„Getting Started
    • Study Plan
    • Optimizing Revision
    • Summer 2024 Timeline
    • FAQs
  • 🄨Algorithms
    • Binary Search
    • Sorting
    • Recursion
    • Graph
    • Quick Select
    • Intervals
    • Binary
    • Geometry
    • Dynamic Programming
  • šŸ„žData Structures
    • Arrays
      • Matrices
    • Strings
    • Linked Lists
      • Doubly Linked Lists
    • Hash Tables
    • Graphs
      • Trees
        • Binary Search Trees
        • Heaps
        • Tries
        • Segment Trees
    • Stacks
    • Queues
      • Double Ended Queues
    • Union-Find Disjoint Set (UFDS)
  • šŸ”Problems Guide
    • Dynamic Programming Roadmap
      • Warmup
        • Climbing Stairs
        • Nth Tribonacci Number
        • Perfect Squares
      • Linear Sequence
        • Min Cost to Climb Stairs
        • Minimum Time to Make Rope Colorful
        • House Robber
        • Decode Ways
        • Minimum Cost for Tickets
        • Solving Questions with Brainpower
  • šŸ£Other Technical Topics
    • General Problem Solving
    • Runtime Predictions
    • System Design
      • SQL
      • Accessing APIs
    • Operating Systems
  • šŸæNon-technical Topics
    • Behavioral Interviews
    • Resumes
Powered by GitBook
On this page
  • Runtime analysis
  • Corner cases
  • Take note...
  • Techniques
  1. Data Structures

Strings

String problems are very similar to array problems as they both use very similar techniques but there are some slight differences

Runtime analysis

Similar to Arrayswith some differences:

  1. Concatenation: O(m+n)O(m + n)O(m+n)

  2. Find substring: O(mƗn)O(m \times n)O(mƗn) (can be improved using Rabin Karp)

  3. Slice: O(m)O(m)O(m)

  4. Split by token: O(m+n)O(m + n)O(m+n)

  5. Strip: O(n)O(n)O(n)

Corner cases

  1. Empty strings

  2. Strings with 1 or 2 characters

  3. Strings with repeated characters

  4. Strings with only distinct characters

Take note...

  1. Input character set (ASCII, UTF-8, all lowercase alphabets, etc.)

  2. Case sensitivity

Techniques

Similar to Arrayswith some additions:

  1. Think about using two pointers more

  2. Count the frequency of characters using a fingerprint frequency array over a hash table if input character set is fixed size

  3. Bitmasking to find duplicates

  4. Anagram checking using frequency over sorting

  5. Palindrome checking using converging two pointers

  6. Counting the number of palindromes using two pointers diverging from middle

PreviousMatricesNextLinked Lists

Last updated 1 year ago

šŸ„ž