0% found this document useful (0 votes)
2 views3 pages

Coding

The document outlines various string and array manipulation problems along with their inputs and expected outputs. Key problems include reversing words in a sentence, checking for anagrams, and finding duplicates in a string. It also covers array operations such as reversing an array, finding maximum and minimum elements, and sorting elements.

Uploaded by

ffp900h
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Coding

The document outlines various string and array manipulation problems along with their inputs and expected outputs. Key problems include reversing words in a sentence, checking for anagrams, and finding duplicates in a string. It also covers array operations such as reversing an array, finding maximum and minimum elements, and sorting elements.

Uploaded by

ffp900h
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

String based Problems

Reverse Words in a Sentence


Input: "Java is fun" → Output: "fun is Java"

Check for Rota on


Given two strings, check if one is a rota on of another.
Input: "ABCD", "CDAB" → Output: true

Run-Length Encoding
Input: "aaabbc" → Output: "a3b2c1"

First Non-Repea ng Character


Input: "swiss" → Output: 'w'

Remove Characters Present in Another String


Given str1 and str2, remove characters from str1 that appear in str2.

Count Vowels and Consonants


Input: "Hello World" → Output: Vowels: 3, Consonants: 7

Check for Anagram


Input: "listen", "silent" → Output: true

Find All Duplicates in a String


Input: "programming" → Output: 'r', 'g', 'm'

Convert to Title Case


Input: "java is awesome" → Output: "Java Is Awesome"

Longest Substring Without Repea ng Characters


Input: "abcabcbb" → Output: "abc" (Length: 3)

Longest Palindromic Substring


Input: "babad" → Output: "bab" or "aba"
Group Anagrams from List of Strings
Input: ["eat", "tea", "tan", "ate", "nat", "bat"]

Minimum Window Substring


Find the smallest substring of S that contains all characters of T.

Find All Permuta ons of a String


Input: "abc" → Output: "abc", "acb", "bac", "bca", "cab", "cba"

Validate Email Format


Use regex to validate an email like someone@[Link].

Check if String is a Number


Input: "123", "12.34", "abc" → Output: true, true, false

Extract Integers from a String


Input: "abc123def45" → Output: [123, 45]

Convert Roman Numerals to Integer


Input: "XIV" → Output: 14

Check Balanced Parentheses


Input: "(){}[]" → Output: true
Input "{)" => OutPut

Mo ons Right to Le the order


Input: "abcde
Input : k if k =1
Output:"eabcd"

Array

1. Reverse an Array/String
Input: [1, 2, 3, 4, 5]
Output: [5, 4, 3, 2, 1]
2. Find the Maximum and Minimum Element in an Array
Input: [3, 5, 1, 8, -2]
Output: Max = 8, Min = -2 3. Find the Kth Maximum and Minimum Element of an Array
Input: [7, 10, 4, 3, 20, 15], k = 3
Output: 3rd Min = 7, 3rd Max = 10
4. Sort 0s, 1s, 2s
Input: [0, 2, 1, 2, 0]
Output: [0, 0, 1, 2, 2]
5. Move All Nega ve Elements to One Side
Input: [1, -1, 3, 2, -7, -5, 11, 6]
Output: [-1, -7, -5, 1, 3, 2, 11, 6] (any order with all nega ves on one side is fine)
6. Find Union and Intersec on of Two Sorted Arrays
Input: arr1 = [1, 2, 4, 5], arr2 = [2, 3, 5, 6]
Output: Union = [1, 2, 3, 4, 5, 6]
Intersec on = [2, 5]
7. Cyclically Rotate an Array by One
Input: [1, 2, 3, 4, 5]
Output: [5, 1, 2, 3, 4]
8. Largest Sum Con guous Subarray (Kadane’s Algorithm)
Input: [-2, -3, 4, -1, -2, 1, 5, -3]
Output: Max Sum = 7 (Subarray: [4, -1, -2, 1, 5])

You might also like