Leetcode 0242. Valid Anagram

Posted on Mon 16 December 2024 in Leetcode • Tagged with string

Question Link : https://leetcode.com/problems/valid-anagram/

Difficulty: Easy

Premium: False

Question

Given two strings s and t, return true if t is an anagram of s, and false otherwise.   Example 1:

Input: s = "anagram", t = "nagaram" Output: true

Example 2:

Input: s = "rat", t = "car" Output: false

Constraints:

1 …


Continue reading

Leetcode 0415. Add Strings

Posted on Mon 18 November 2024 in Leetcode • Tagged with string

Question Link : https://leetcode.com/problems/add-strings/

Difficulty: Easy

Premium: False

Question

Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string. You must solve the problem without using any built-in library for handling large integers (such as BigInteger). You …


Continue reading

Leetcode 3110. Score of a String

Posted on Sun 11 August 2024 in Leetcode • Tagged with string

Question Link : https://leetcode.com/problems/score-of-a-string/

Difficulty: Easy

Premium: False

Question

You are given a string s. The score of a string is defined as the sum of the absolute difference between the ASCII values of adjacent characters. Return the score of s.   Example 1:

Input: s = "hello" Output …


Continue reading

Leetcode 2405. Optimal Partition of String

Posted on Mon 03 April 2023 in Leetcode • Tagged with string, greedy

Question Link : https://leetcode.com/problems/optimal-partition-of-string/

Difficulty: Medium

Premium: False

Question

Given a string s, partition the string into one or more substrings such that the characters in each substring are unique. That is, no letter appears in a single substring more than once. Return the minimum number of …


Continue reading

Leetcode 1704. Determine if String Halves Are Alike

Posted on Wed 30 November 2022 in Leetcode • Tagged with string

Question Link : https://leetcode.com/problems/determine-if-string-halves-are-alike/

Difficulty: Easy

Premium: False

Question

You are given a string s of even length. Split this string into two halves of equal lengths, and let a be the first half and b be the second half. Two strings are alike if they have …


Continue reading

Leetcode 0345. Reverse Vowels of a String

Posted on Thu 03 November 2022 in Leetcode • Tagged with two-pointers, string

Question Link : https://leetcode.com/problems/reverse-vowels-of-a-string/

Difficulty: Easy

Question

Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both lower and upper cases, more than once.   Example 1: Input …


Continue reading

Leetcode 2131. Longest Palindrome by Concatenating Two Letter Words

Posted on Wed 02 November 2022 in Leetcode • Tagged with palindrome, string

Question Link : https://leetcode.com/problems/longest-palindrome-by-concatenating-two-letter-words/

Difficulty: Medium

Question

You are given an array of strings words. Each element of words consists of two lowercase English letters. Create the longest possible palindrome by selecting some elements from words and concatenating them in any order. Each element can be selected …


Continue reading

Leetcode 1662. Check If Two String Arrays are Equivalent

Posted on Mon 24 October 2022 in Leetcode • Tagged with string

Question Link : https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent/

Difficulty: Easy

Question

Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise. A string is represented by an array if the array elements concatenated in order forms the string.   Example 1:

Input …


Continue reading

Leetcode 0647. Palindromic Substrings

Posted on Mon 23 May 2022 in Leetcode • Tagged with palindrome, string

Question Link : https://leetcode.com/problems/palindromic-substrings/

Difficulty: Medium

Question

Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.   Example 1:

Input: s …


Continue reading

Leetcode 0344. Reverse String

Posted on Thu 31 March 2022 in Leetcode • Tagged with string

Question Link : https://leetcode.com/problems/reverse-string/

Difficulty: Easy

Question

Write a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the input array in-place with O(1) extra memory.   Example 1: Input: s = ["h","e","l …


Continue reading