Saving and Restoring Activity Instance State Using the Lifecycle Handlers

Activities offer the onSaveInstanceState handler to persist data associated with UI state across sessions. It’s designed specifically to persist UI state should an Activity be terminated by the run time, either in an effort to free resources for foreground applications or to accommodate restarts caused by hardware configuration changes If an Activity is closed by … Read more

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