Given two strings haystack and needle , find the index of the first occurrence of needle in haystack . If needle is not present in haystack , return -1 . tuf-examples-1 Input: haystack = "sadbutsad...
Problem Statement An array nums contains positive integers. Divide all array elements into two disjoint subsets so every element belongs to exactly one subset. Return true when both subsets can hav...
Problem Statement An array coins containing distinct positive coin denominations and a non-negative integer amount are given. Every denomination may be selected any number of times. Return the mini...
Problem Statement Two equal-length arrays weights and values describe available items. Entries at the same index form one item with a weight and a value. A non-negative integer capacity gives the m...
Problem Statement Given a string s , find the length of the longest palindromic subsequence. A subsequence may skip characters but must preserve the relative order of every selected character. Sele...
Problem Statement Given two strings firstText and secondText , return the length of the longest character sequence appearing in both strings in the same relative order. A subsequence may delete zer...
Problem Statement Given two sorted arrays nums1 of size m+n and nums2 of size n, where nums1 holds m valid elements followed by n zeros, merge nums2 into nums1 so the result is a single sorted arra...
Problem Statement Given an array candidates containing distinct positive integers and an integer target , return all unique combinations with chosen numbers summing to target . The sa...
Input: s = "aab" Output: [["a", "a", "b"], ["aa", "b"]] Explanation: Both partitions cover the full string and every part is a palindrome. Input: s = "a" Output: [["a"]] Explanation: A single chara...
Problem Statement Given an n x n binary matrix maze , a rat starts at cell (0, 0) and must reach cell (n - 1, n - 1) . A cell with value 1 is open, and a cell with value 0 is blocked. Return all po...
Input: arr = [5, 5, 4, 6, 4] Output: [4, 4, 5, 5, 6] Explanation: Values 4 and 5 appear 2 times each. Smaller value 4 comes before 5 , while value 6 comes last with frequency 1 . Input: arr = [3, -...
Problem Statement An integer array nums and a positive integer k are given. A window containing exactly k consecutive elements starts at the left end of the array and moves right by one position at...