Evan Blog

Algorithms

House Robber

Leetcode-198

House Robber Question You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of th...

Reverse Integer

Leetcode-7

Reverse Integer Question Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 No...

Maximum Length of Repeated Subarray

Leetcode-718

Maximum Length of Repeated Subarray Question Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays. Example 1: Input: A: [1,2,3,2,1] B: [3,2,1,4,7]...

Is Subsequence

Leetcode-392

Is Subsequence Question Given a string s and a string t, check if s is subsequence of t. You may assume that there is only lower case English letters in both s and t. t is potentially a very long ...

Predict the Winner

Leetcode-486

Predict the Winner Question Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so...

Merge Two Sorted Lists

Leetcode-21

Merge Two Sorted Lists Question Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Answer 这道题比较简单,就是归并的链表...

Letter Combinations of a Phone Number

Leetcode-17

Letter Combinations of a Phone Number Question Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telep...

Palindromic Substrings

Leetcode-647

Palindromic Substrings Question Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are counted as diff...

House Robber II

Leetcode-213

House Robber II Question Note: This is an extension of House Robber. After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too...

Search a 2D Matrix II

Leetcode-240

Search a 2D Matrix II Question Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted in ascending ...