Implement strstr() using java

Question Implement strstr(). Returns the index of the first occurrence of needle in haystack, or –1 if needle is not part of haystack. Solution: O(nm) runtime, O(1) space – Brute force: There are known efficient algorithms such as Rabin-Karp algorithm, KMP algorithm, orthe Boyer-Moore algorithm. Since these algorithms are usually studied in an advancedalgorithms class, … Read more

Leetcode Valid Palindrome String

Question: Given a string, determine if it is a palindrome, considering only alphanumeric charactersand ignoring cases.For example,“A man, a plan, a canal: Panama” is a palindrome.“race a car” is not a palindrome Example Questions Candidate Might Ask: Q: What about an empty string? Is it a valid palindrome?A: For the purpose of this problem, we … Read more