Easy Strings Interview Questions

We'll now go through our first section that's chock-full of challenges. After learning about the most important patterns for linear data structures, we'll get some practice with basic string problems.

Recall that a string is sequence of characters, either as a literal constant or as some kind of variable, that can usually have its elements be mutated and length changed. Due to their prevalence in day-to-day programming, they account for a significant amount of the problems you may encounter in interviews.

After we wrap, we'll move onto some basic array interview problems.

Section Menu

How do I use this section?

1. CHALLENGE

Reverse a String

Hey there, welcome to the challenges portion of the AlgoDaily technical interview course! Over the next few days, you'll get some hands-on experience with the essential data structures and algorithms that will help you nail your interview, and land your dream software engineering job. The only way to get better at solvin...

2. CHALLENGE

Fizz Buzz

Fizz Buzz is a classic interview question that apparently many experienced engineering candidates often can't solve! Let's cover it today. We're given a number in the form of an integer n. Write a function that returns the string representation of all numbers from 1 to n based on the following rules: If it's a multiple o...

3. CHALLENGE

Reverse Only Alphabetical

Reversing Only Alphabetical Characters in a String Visual Diagram The Problem Statement You are provided with a string that's a blend of alphabetic and non-alphabetic characters. Think of a beach where you find b...

4. CHALLENGE

Is An Anagram

Understanding Anagrams: A Simple Definition An anagram is a fascinating literary device where you can rearrange the letters of a word, phrase, or name to form another meaningful sequence. Think of it as a jigsaw puzzle made of letters. For example, the word "cinema" can be rearranged to form "iceman." The Challenge: Detecti...

5. CHALLENGE

Validate Palindrome

Given a string str, can you write a method that will return True if is a palindrome and False if it is not? If you'll recall, a palindrome is defined as "a word, phrase, or sequence that reads the same backward as forward". For now, assume that we will not have input strings that contain special characters or spaces, so the...

6. CHALLENGE

Sum Digits Until One

We're provided a positive integer num. Can you write a method to repeatedly add all of its digits until the result has only one digit? Here's an example: if the input was 49, we'd go through the following steps: // start with 49 4 + 9 = 13 // since the previous addition was 13, // move onto summing 13's digits 1 + 3 = 4...

7. CHALLENGE

Detect Substring in String

How would you write a function to detect a substring in a string? If the substring can be found in the string, return the index at which it starts. Otherwise, return -1. `js funct...

8. CHALLENGE

Dollar Sign Deletion

You're given an array of strings containing alphabetical characters and certain $ characters. A $ represents a DELETE action whereby the character before it is deleted. Each of these strings will be run through a method to operate on the $ DELETE action. We want to find out if the final string is the same for all of them. Le...

9. CHALLENGE

Find First Non-Repeating Character

You're given a string of random alphanumerical characters with a length between 0 and 1000. Write a method to return the first character in the string that does not repeat itself later on. So i...

10. CHALLENGE

Find Duplicate Words

A very common interview challenge is to determine how often words appear in a given string or set of strings. Here's a version of this: return a list of duplicate words in a sentence....

11. CHALLENGE

Remove All Adjacent Duplicates In String

The Concept: Removing Adjacent Duplicates Imagine you're attending a magical carnival where you can pull adjacent duplicate letters from a string like pulling rabbits out of a hat. Exciting, right? Your goal is to get a clean string with no adjacent duplicates. In this lesson, we'll explore this problem with Linda's candy adven...

12. CHALLENGE

Custom Sort String

We are given two strings order and str, with the string order already sorted in a custom order. Permute the characters of str such that they match the custom order in which order is sorted. More specifically, if a character x occurs before a character y in order, then x should occur before y in the permuted stri...

13. CHALLENGE

Simplifying Absolute Paths

Here is how I would enrich the absolute path simplification problem with more details and walkthroughs: Simplifying Absolute Paths In Unix, an absolute path locates a file/directory from the root directory. It can contain: . - Stands for the current directory .. - Stands for the parent directory Multiple / - Tr...

14. CHALLENGE

Length of Longest Palindromic Subsequence

Question/Prompt A palindrome is a word, phrase, or sequence that reads the same backward or forwards. A palindromic subsequence is a palindrome derived from a sequence by deleting some or no elements from it. This subsequence is formed without changing the order of the elements in the original sequence. Given a string s,...