随笔分类 -  normal problem

890. Find and Replace Pattern
摘要:You have a list of words and a pattern, and you want to know which words in words matches the pattern. A word matches the pattern if there exists a permutation of letters p so that after replacing ev... 阅读全文

posted @ 2018-11-29 07:22 猪猪🐷

939. Minimum Area Rectangle
摘要:Given a set of points in the xy-plane, determine the minimum area of a rectangle formed from these points, with sides parallel to the x and y axes. If 阅读全文

posted @ 2018-11-27 15:17 猪猪🐷

135. Candy
摘要:follow up:如何不使用extra space解决这道题 https://leetcode.com/problems/candy/solution/ Approach 4: Single Pass Approach with Constant Space Algorithm https://leetcode.com/problems/candy/discuss/42770/On... 阅读全文

posted @ 2018-11-09 10:43 猪猪🐷

807. Max Increase to Keep City Skyline
摘要:In a 2 dimensional array grid, each value grid[i][j] represents the height of a building located there. We are allowed to increase the height of any number of buildings, by any amount (the amounts ca... 阅读全文

posted @ 2018-11-09 10:39 猪猪🐷

14. 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:... 阅读全文

posted @ 2018-11-09 10:38 猪猪🐷

611. Valid Triangle Number
摘要:Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. Example 1: ... 阅读全文

posted @ 2018-11-09 10:19 猪猪🐷

6. ZigZag Conversion
摘要:https://www.youtube.com/watch?v=8zXTAn7i5rU The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for... 阅读全文

posted @ 2018-11-09 10:17 猪猪🐷

624. Maximum Distance in Arrays
摘要:Given m arrays, and each array is sorted in ascending order. Now you can pick up two integers from two different arrays (each array picks one) and calculate the distance. We define the distance betwe... 阅读全文

posted @ 2018-11-09 07:39 猪猪🐷

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 th... 阅读全文

posted @ 2018-11-09 07:10 猪猪🐷

819. Most Common Word
摘要:Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at least one word that isn't banned, and that the answe... 阅读全文

posted @ 2018-11-09 06:37 猪猪🐷

36. Valid Sudoku
摘要:Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: 1. Each row must contain the digits 1-9 without repetition. 2. Each column mu... 阅读全文

posted @ 2018-11-08 17:08 猪猪🐷

535. Encode and Decode TinyURL
摘要:535. Encode and Decode TinyURL Note: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/... 阅读全文

posted @ 2018-11-08 17:04 猪猪🐷

859. Buddy Strings
摘要:Given two strings A and B of lowercase letters, return true if and only if we can swap two letters in A so that the result equals B. Example 1: Input: A = "ab", B = "ba" Output: true Example 2: ... 阅读全文

posted @ 2018-11-08 16:21 猪猪🐷

821. Shortest Distance to a Character
摘要:https://leetcode.com/problems/shortest-distance-to-a-character/solution/ // three pass, accepted class Solution { public int[] shortestToChar(String S, char C) { // left scan , upda... 阅读全文

posted @ 2018-11-08 16:10 猪猪🐷

836. Rectangle Overlap
摘要:A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of its bottom-left corner, and (x2, y2) are the coordinates 阅读全文

posted @ 2018-11-08 16:10 猪猪🐷

165. Compare Version Numbers
摘要:Compare two version numbers version1 and version2.
If version1 > version2 return 1; if version1 version2.charAt(i) - '0'){ return 1; }else if(version1.charAt(i) - '0' ve... 阅读全文

posted @ 2018-11-08 16:00 猪猪🐷

271. Encode and Decode Strings
摘要:Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings. Machine 1 (sender) has the function:... 阅读全文

posted @ 2018-11-08 15:37 猪猪🐷

387. First Unique Character in a String
摘要:Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note: You may as... 阅读全文

posted @ 2018-11-08 02:24 猪猪🐷

567. Permutation in String
摘要:Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string's permutations is the substring of the second string. Exampl... 阅读全文

posted @ 2018-11-08 02:18 猪猪🐷

217. Contains Duplicate
摘要:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element i... 阅读全文

posted @ 2018-11-08 02:16 猪猪🐷

导航