随笔分类 -  Algorithms

LeetCode212. Word Search II
摘要:https://leetcode.com/problems/word-search-ii/description/ Given a 2D board and a list of words from the dictionary, find all words in the board. Each 阅读全文
posted @ 2018-08-13 22:11 f91og 阅读(445) 评论(0) 推荐(0)
LeetCode132. Palindrome Partitioning II
摘要:Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning 阅读全文
posted @ 2018-08-13 02:40 f91og 阅读(185) 评论(0) 推荐(0)
LeetCode239. Sliding Window Maximum
摘要:Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k num 阅读全文
posted @ 2018-08-13 02:25 f91og 阅读(160) 评论(0) 推荐(0)
LeetCode解题报告—— Interleaving String
摘要:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. Example 1: Example 2: 思路 可以遍历s1和s2所能构成的所有可能的interlaving string。 We start 阅读全文
posted @ 2018-08-10 00:42 f91og 阅读(314) 评论(0) 推荐(0)
LeetCode解题报告—— Maximal Rectangle
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example: 思路 看了下discussion,真的很难理解 阅读全文
posted @ 2018-08-08 20:56 f91og 阅读(332) 评论(0) 推荐(0)
LeetCode解题报告—— Minimum Window Substring && Largest Rectangle in Histogram
摘要:1. Minimum Window Substring Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n 阅读全文
posted @ 2018-08-08 01:40 f91og 阅读(253) 评论(0) 推荐(0)
LeetCode解题报告—— N-Queens && Edit Distance
摘要:1. N-Queens The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, 阅读全文
posted @ 2018-08-05 16:58 f91og 阅读(232) 评论(0) 推荐(0)
LeetCode解题报告—— Trapping Rain Water
摘要:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. 阅读全文
posted @ 2018-08-05 15:06 f91og 阅读(398) 评论(0) 推荐(0)
LeetCode解题报告—— Longest Valid Parentheses
摘要:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Example 1: Exampl 阅读全文
posted @ 2018-08-03 23:56 f91og 阅读(166) 评论(0) 推荐(0)
LeetCode解题报告—— Reverse Nodes in k-Group && Sudoku Solver
摘要:1. Reverse Nodes in k-Group Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer 阅读全文
posted @ 2018-08-03 22:48 f91og 阅读(321) 评论(0) 推荐(0)
LeetCode解题报告—— Regular Expression Matching
摘要:Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'. The matching should cover the entire  阅读全文
posted @ 2018-07-31 16:27 f91og 阅读(317) 评论(0) 推荐(0)
[编程题] 合唱团 && 地闹逃脱
摘要:1. 合唱团 有 n 个学生站成一排,每个学生有一个能力值,牛牛想从这 n 个学生中按照顺序选取 k 名学生,要求相邻两个学生的位置编号的差不超过 d,使得这 k 个学生的能力值的乘积最大,你能返回最大的乘积吗? 思路:想到了用dp来解这题,但是接下来建立dp模型时却遇到了很多困难,尝试用 dp[n 阅读全文
posted @ 2018-07-31 16:16 f91og 阅读(401) 评论(0) 推荐(0)
LeetCode解题报告—— Median of Two Sorted Arrays
摘要:There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sh 阅读全文
posted @ 2018-07-21 16:57 f91og 阅读(255) 评论(0) 推荐(0)
LeetCode解题报告—— Bus Routes
摘要:We have a list of bus routes. Each routes[i] is a bus route that the i-th bus repeats forever. For example if routes[0] = [1, 5, 7], this means that t 阅读全文
posted @ 2018-07-17 23:17 f91og 阅读(497) 评论(0) 推荐(0)
LeetCode解题报告—— Number of Islands & Bitwise AND of Numbers Range
摘要:1. Number of Islands Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed 阅读全文
posted @ 2018-06-01 17:20 f91og 阅读(193) 评论(0) 推荐(0)
LeetCode解题报告—— Linked List Cycle II & Reverse Words in a String & Fraction to Recurring Decimal
摘要:1. Linked List Cycle II Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked 阅读全文
posted @ 2018-05-25 01:24 f91og 阅读(213) 评论(0) 推荐(0)
LeetCode解题报告—— Sum Root to Leaf Numbers & Surrounded Regions & Single Number II
摘要:1. Sum Root to Leaf Numbers Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the ro 阅读全文
posted @ 2018-05-13 02:21 f91og 阅读(194) 评论(0) 推荐(0)
LeetCode解题报告——Convert Sorted List to Binary Search Tree & Populating Next Right Pointers in Each Node & Word Ladder
摘要:1. Convert Sorted List to Binary Search Tree Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced 阅读全文
posted @ 2018-04-23 14:22 f91og 阅读(192) 评论(0) 推荐(0)
LeetCode解题报告—— Unique Binary Search Trees & Binary Tree Level Order Traversal & Binary Tree Zigzag Level Order Traversal
摘要:1. Unique Binary Search Trees Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, ther 阅读全文
posted @ 2018-04-02 20:57 f91og 阅读(219) 评论(0) 推荐(0)
LeetCode解题报告—— Reverse Linked List II & Restore IP Addresses & Unique Binary Search Trees II
摘要:1. Reverse Linked List II Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and 阅读全文
posted @ 2018-03-31 18:41 f91og 阅读(123) 评论(0) 推荐(0)