随笔分类 - Leetcode
摘要:题目大意 https://leetcode.com/problems/search-a-2d-matrix-ii/ 240. Search a 2D Matrix II Write an efficient algorithm that searches for a value in an m x
阅读全文
摘要:题目大意 https://leetcode.com/problems/kth-smallest-element-in-a-bst/description/ 230. Kth Smallest Element in a BST Given a binary search tree, write a f
阅读全文
摘要:题目大意 https://leetcode.com/problems/generate-parentheses/description/ 22. Generate Parentheses Given n pairs of parentheses, write a function to genera
阅读全文
摘要:题目大意 https://leetcode.com/problems/unique-paths/description/ 62. Unique Paths A robot is located at the top-left corner of a m x n grid (marked 'Start
阅读全文
摘要:题目大意 https://leetcode.com/problems/find-the-duplicate-number/description/ 287. Find the Duplicate Number Given an array nums containing n + 1 integers
阅读全文
摘要:题目大意 https://leetcode.com/problems/product-of-array-except-self/description/ 238. Product of Array Except Self Given an array nums of n integers where
阅读全文
摘要:题目大意 https://leetcode.com/problems/binary-tree-inorder-traversal/description/ 94. Binary Tree Inorder Traversal Given a binary tree, return the inorde
阅读全文
摘要:题目大意 https://leetcode.com/problems/count-primes/description/ 204. Count Primes Count the number of prime numbers less than a non-negative number, n. E
阅读全文
摘要:题目大意 判断单链表中是否存在环 解题思路 Approach 1: Hash Table 哈希表 Intuition To detect if a list is cyclic, we can check whether a node had been visited before. A natur
阅读全文
摘要:题目大意 解题思路 关键点:左子树和右子树成镜像关系,根树与本身成镜像关系。 Approach 1: Recursive 递归法 A tree is symmetric if the left subtree is a mirror reflection of the right subtree.
阅读全文
摘要:1.获取第k行(以k=10为例) 要注意的是,如果文件包含内容不足10行,应该不输出. 另外,输出第5行到第8行: 题目来自Leetcode的195. Tenth Line 解法参考:http://bookshadow.com/weblog/2015/03/28/leetcode-tenth-lin
阅读全文
摘要:""" http://bookshadow.com/weblog/2015/10/12/leetcode-nim-game/ 292. Nim Game You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you...
阅读全文