随笔分类 -  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 阅读全文
posted @ 2018-11-02 16:51 焦距 阅读(341) 评论(0) 推荐(0) 编辑
摘要:题目大意 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 阅读全文
posted @ 2018-09-18 10:04 焦距 阅读(785) 评论(0) 推荐(0) 编辑
摘要:题目大意 https://leetcode.com/problems/generate-parentheses/description/ 22. Generate Parentheses Given n pairs of parentheses, write a function to genera 阅读全文
posted @ 2018-09-14 10:08 焦距 阅读(306) 评论(0) 推荐(0) 编辑
摘要:题目大意 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 阅读全文
posted @ 2018-09-12 16:10 焦距 阅读(364) 评论(0) 推荐(0) 编辑
摘要:题目大意 https://leetcode.com/problems/find-the-duplicate-number/description/ 287. Find the Duplicate Number Given an array nums containing n + 1 integers 阅读全文
posted @ 2018-09-07 10:42 焦距 阅读(893) 评论(0) 推荐(0) 编辑
摘要:题目大意 https://leetcode.com/problems/product-of-array-except-self/description/ 238. Product of Array Except Self Given an array nums of n integers where 阅读全文
posted @ 2018-09-06 10:43 焦距 阅读(497) 评论(0) 推荐(0) 编辑
摘要:题目大意 https://leetcode.com/problems/binary-tree-inorder-traversal/description/ 94. Binary Tree Inorder Traversal Given a binary tree, return the inorde 阅读全文
posted @ 2018-09-05 11:20 焦距 阅读(666) 评论(0) 推荐(0) 编辑
摘要:题目大意 https://leetcode.com/problems/count-primes/description/ 204. Count Primes Count the number of prime numbers less than a non-negative number, n. E 阅读全文
posted @ 2018-09-04 10:05 焦距 阅读(677) 评论(0) 推荐(0) 编辑
摘要:题目大意 判断单链表中是否存在环 解题思路 Approach 1: Hash Table 哈希表 Intuition To detect if a list is cyclic, we can check whether a node had been visited before. A natur 阅读全文
posted @ 2018-08-31 10:15 焦距 阅读(406) 评论(0) 推荐(0) 编辑
摘要:题目大意 解题思路 关键点:左子树和右子树成镜像关系,根树与本身成镜像关系。 Approach 1: Recursive 递归法 A tree is symmetric if the left subtree is a mirror reflection of the right subtree. 阅读全文
posted @ 2018-08-30 10:39 焦距 阅读(433) 评论(0) 推荐(0) 编辑
摘要:1.获取第k行(以k=10为例) 要注意的是,如果文件包含内容不足10行,应该不输出. 另外,输出第5行到第8行: 题目来自Leetcode的195. Tenth Line 解法参考:http://bookshadow.com/weblog/2015/03/28/leetcode-tenth-lin 阅读全文
posted @ 2017-12-06 10:59 焦距 阅读(13400) 评论(2) 推荐(1) 编辑
摘要:""" 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... 阅读全文
posted @ 2017-11-14 10:12 焦距 阅读(231) 评论(0) 推荐(0) 编辑