Let’s UnderStand What is String?
In computer programming, a string is a sequence of
characters, typically used to represent text. In most
programming languages, a string is considered a data
type, and it is often used to store and manipulate
textual data.
A character in a string can be any symbol, including
letters, numbers, punctuation, and whitespace.
Strings are usually enclosed in quotation marks. The
type of quotation marks (single or double) depends on
the programming language, but the common practice
is to use either single or double quotes consistently
throughout your code.
01
Now, It’s Time For Practice :)
01. Reverse Words in a String
Given an input string s, reverse the order of the words.
A word is defined as a sequence of non-space characters.
The words in s will be separated by at least one space.
Return a string of the words in reverse order
concatenated by a single space.
Practice
02. Longest Palindromic Substring
Given a string s, return the longest palindromic substring
in s.
Practice
02
03. Longest Common Prefix
Write a function to find the longest common prefix string
amongst an array of strings.
If there is no common prefix, return an empty string "".
Practice
04. Repeated String Match
Given two strings a and b, return the minimum number of
times you should repeat string a so that string b is a
substring of it. If it is impossible for bto be a substring of
a after repeating it, return -1.
Notice: string "abc" repeated 0 times is "", repeated 1
time is "abc" and repeated 2 times is "abcabc".
Practice
03
05. Valid Anagram
Given two strings s and t, return true if t is an anagram of
s, and false otherwise.
An Anagram is a word or phrase formed by rearranging
the letters of a different word or phrase, typically using
all the original letters exactly once.
Practice
06. Valid Palindrome II
Given a string s, return true if the s can be palindrome
after deleting at most one character from it.
Practice
07. Integer to English Words
Convert a non-negative integer num to its English words
representation.
Practice
04
08. Group Anagrams
Given an array of strings strs, group the anagrams
together. You can return the answer in any order.
An Anagram is a word or phrase formed by rearranging
the letters of a different word or phrase, typically using
all the original letters exactly once.
Practice
09. Basic Calculator II
Given a string s which represents an expression, evaluate
this expression and return its value.
The integer division should truncate toward zero.
You may assume that the given expression is always valid.
All intermediate results will be in the range of [-231, 231 - 1].
Practice
05
10. Text Justification
Given an array of strings words and a width maxWidth,
format the text such that each line has exactly maxWidth
characters and is fully (left and right) justified.
You should pack your words in a greedy approach; that is,
pack as many words as you can in each line. Pad extra
spaces ' ' when necessary so that each line has exactly
maxWidth characters.
Extra spaces between words should be distributed as
evenly as possible. If the number of spaces on a line does
not divide evenly between words, the empty slots on the
left will be assigned more spaces than the slots on the
right.
For the last line of text, it should be left-justified, and no
extra space is inserted between words.
Practice
06