- String Compression
- Write a function that takes a string and compresses it using the counts of repeated characters. For example, the string “aabcccccaaa” should become “a2b1c5a3”. If the compressed string is not smaller than the original string, return the original string.
- Longest Substring Without Repeating Characters
- Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating characters for “abcabcbb” is “abc”, which the length is 3.
- String Permutations
- Write a function to check if two given strings are permutations of each other. For example, “abc” and “bca” are permutations of each other, but “abc” and “abcd” are not.
- Palindrome Substring
- Given a string, find the longest palindromic substring. For example, for the input “babad”, the longest palindromic substring is “bab” or “aba”.
- Regular Expression Matching
- Implement a function to perform basic regular expression matching with support for ‘.’ and ‘‘. The function should take an input string and a pattern and return whether the pattern matches the entire input string. For example, “a” matches “aaa” and “.*” matches any string.
- Anagram Grouping
- Given a list of strings, group the anagrams together. For example, given
["eat", "tea", "tan", "ate", "nat", "bat"]
, return[["eat", "tea", "ate"], ["tan", "nat"], ["bat"]]
.
- Given a list of strings, group the anagrams together. For example, given
- ZigZag Conversion
- Write a function that converts a string to a zigzag pattern on a given number of rows. For example, the string “PAYPALISHIRING” on 3 rows should be printed
- P A H N
- A P L S I I G
- Y I R
- Word Search in Matrix
- Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where “adjacent” cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.
- Minimum Window Substring
- Given a string
S
and a stringT
, find the minimum window inS
which will contain all the characters inT
. For example,S = "ADOBECODEBANC"
andT = "ABC"
, the minimum window is “BANC”.
- Given a string
- String to Integer (atoi)
- Implement the
atoi
function, which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value.
- Implement the