# Coding Interviews: Arrays and Strings

You are given a string s. You can convert s to a palindrome by adding characters in front of it.

Return *the shortest palindrome you can find by performing this transformation*.

Given a string s, find the length of the **longest** **substring **without repeating characters.

Given a string **S** and an integer **K**, return *the length of the longest substring of* **S** *that contains at most* **K** **distinct*** characters*.

Given an integer array nums, you need to find one **continuous subarray** such that if you only sort this subarray in non-decreasing order, then the whole array will be sorted in non-decreasing order.

Return *the shortest such subarray and output its length*.

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.

You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and intervals is sorted in ascending order by starti. You are also given an interval newInterval = [start, end] that represents the start and end of another interval.

Insert newInterval into intervals such that intervals is still sorted in ascending order by starti and intervals still does not have any overlapping intervals (merge overlapping intervals if necessary).

Return intervals* after the insertion*.

**Note** that you don't need to modify intervals in-place. You can make a new array and return it.

Given two binary strings a and b, return *their sum as a binary string*. ie "01" and "10" as strings add to "11"

Given a set of distinct integers, return the power set (all possible subsets including the empty set)

You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels.

Letters are case sensitive, so "a" is considered a different type of stone from "A".

Given an encoded string, return its decoded string.

The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer.

You may assume that the input string is always valid; there are no extra white spaces, square brackets are well-formed, etc. Furthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat numbers, k. For example, there will not be input like 3a or 2[4].

Given an array of integers nums, *find the next lexographically ordered permutation of* nums. For example, the next permutation of arr = [1,2,3] is [1,3,2].

Given an array of integers nums and an integer k, return *the total number of subarrays whose sum equals to* k.

A subarray is a contiguous **non-empty** sequence of elements within an array.

Given an integer array nums, rotate the array to the right by k steps, where k is non-negative.

Given an integer array nums sorted in **increasing order**, remove the duplicates in place such that each unique element appears only **once**. The **relative order** of the elements should be kept the **same**. Then return *the number of unique elements in *nums.

Given two strings s and p, return *an array of all the start indices of *p*'s anagrams in *s. You may 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.

Design an algorithm to serialize and deserialize a binary tree into a string.

Given two strings s and t of lengths m and n respectively, return *the ***minimum window**

**substring***of *s* such that every character in *t* (***including duplicates***) is included in the window*. If there is no such substring, return *the empty string *"".

The testcases will be generated such that the answer is **unique**.

Write a program to solve a Sudoku puzzle by filling the empty cells.

A sudoku solution must satisfy **all of the following rules**:

Each of the digits 1-9 must occur exactly once in each row.

Each of the digits 1-9 must occur exactly once in each column.

Each of the digits 1-9 must occur exactly once in each of the 9 3x3 sub-boxes of the grid.

The '.' character indicates empty cells.

You are given two integer arrays nums1 and nums2, sorted in **non-decreasing order**, and two integers m and n, representing the number of elements in nums1 and nums2 respectively.

**Merge** nums1 and nums2 into a single array sorted in **non-decreasing order**.

The final sorted array should not be returned by the function, but instead be *stored inside the array *nums1. To accommodate this, nums1 has a length of m + n, where the first m elements denote the elements that should be merged, and the last n elements are set to 0 and should be ignored. nums2 has a length of n.

Given a string s, *find the first non-repeating character in it and return its index*. If it does not exist, return -1