Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "".Example 1:Input: ["flower","flow","flight"] Output: "fl" Example 2:Input: ["dog","racecar","car"] Output: "" Explanation: There is no common prefix among the input strings. Note:All given inputs are in lowercase letters a-z. My solution:class Solution: def.. 더보기 Implement strStr() Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll" Output: 2 Example 2:Input: haystack = "aaaaa", needle = "bba" Output: -1 Clarification:What should we return when needle is an empty string? This is a great question to ask during an interview.For the purpose of this problem.. 더보기 String to Integer (atoi) Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value.The string can contain additional characters after .. 더보기 Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we define empty string as valid palindrome.Example 1:Input: "A man, a plan, a canal: Panama" Output: true Example 2:Input: "race a car" Output: false My solution:class Solution: def isPalindrome(self, s): """ :type s: str :rtype: bool """ size_s = le.. 더보기 Valid Anagram Given two strings s and t , write a function to determine if t is an anagram of s.Example 1:Input: s = "anagram", t = "nagaram" Output: true Example 2:Input: s = "rat", t = "car" Output: false Note: You may assume the string contains only lowercase alphabets.Follow up: What if the inputs contain unicode characters? How would you adapt your solution to such case? My first solution:class Solution:.. 더보기 Most Frequently Occurring Item in an Array Most Frequently Occurring Item in an Array (Java)Find the most frequently occurring item in an array.Example: The most frequently occurring item in [1, 3, 1, 3, 2, 1] is 1.If you're given an empty array, you should return null (in Java) or None (in Python).You can assume that there is always a single, unique value that appears most frequently unless the array is empty. For instance, you won't be.. 더보기 이전 1 다음