
Leetcode 290 Word Pattern
Leetcode 290 Word Pattern Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a nonempty word in str. Examples: pattern = "abba", str = "dog cat cat dog" should…

Leetcode 14 Longest Common Prefix
Leetcode 14 Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. Firstly, I misunderstand the problem, the problem gives you several strings, and we should find the longest prefix among these strings. public class Solution { public String longestCommonPrefix(String[] strs) { if(…

Leetcode 205 Isomorphic Strings
Leetcode 205 Isomorphic Strings Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters…

Leetcode 279 Perfect Square
Leetcode 279 Perfect Square Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13, return 2 because 13 = 4 + 9. DP question:…

Leetcode 299 Bulls and Cows
Leetcode 299 Bulls and Cows You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that indicates how many digits in said…