leetcode
文章平均质量分 59
Newpidian
这个作者很懒,什么都没留下…
展开
-
Leetcode之 largest divisible set
题目题目地址 :https://leetcode.com/problems/largest-divisible-subset/题意解析给定一个数组,这个数组数唯一且为正数,求在这个数组中,满足能整除的最大集合。求解很自然地想到用动态,因为满足重叠子问题和最优子结构 重叠子问题:整个数组的最大集合,可以认为是多个子问题组成的 最优子结构:反证法,显而易见。 定义最优解:最大集合是什么。定义最优解原创 2016-08-13 14:23:28 · 710 阅读 · 0 评论 -
前缀树及应用两数异或Leetcode之 Maximum XOR of Two Numbers in an Array
题目 前缀树题目地址:https://leetcode.com/problems/implement-trie-prefix-tree/ 题目地址:https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/ 421. Maximum XOR of Two Numbers in an Array Ques原创 2016-10-18 22:08:26 · 2376 阅读 · 0 评论 -
Leetcode之CoinChange
题目题目地址 https://leetcode.com/problems/coin-change/ You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you原创 2016-10-17 09:58:34 · 643 阅读 · 0 评论 -
华为Oj--识别有效的IP地址和掩码并进行分类统计
华为机试题识别有效的IP地址和掩码并进行分类统计题目描述题目描述请解析IP地址和对应的掩码,进行分类识别。要求按照A/B/C/D/E类地址归类,不合法的地址和掩码单独归类。所有的IP地址划分为 A,B,C,D,E五类A类地址1.0.0.0~126.255.255.255;B类地址128.0.0.0~191.255.255.255;C类地址192.0.0.0~223.255.255.255;D类地址2原创 2016-10-13 10:10:21 · 1633 阅读 · 0 评论 -
Leetcode 之 Insert Delete GetRandom O(1)
题目Design a data structure that supports all following operations in average O(1) time.insert(val): Inserts an item val to the set if not already present.remove(val): Removes an item val from the set原创 2016-08-09 18:32:25 · 1299 阅读 · 0 评论 -
Leetcode之Search for a Range
Search for a Range 题目Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm’s runtime complexity must be in the order of O(log n). If the targ原创 2016-08-07 23:33:38 · 912 阅读 · 2 评论 -
Leetcode 之 Unique Paths
题目 原题目地址:https://leetcode.com/problems/unique-paths/ 题意解析题目的意思是给定一个二维数组网格,从原点(0,0)出发到达最末尾总共有几种路径做法,每次操作的时候只能向右或者向下。 一看到题意 就让我很自然地想到了动态规划,DP问题需要满足2个条件:重叠子问题和最优子结构 其中重叠子问题:显然满足情况。最优子结构:也满足,可以用反证法。定原创 2016-08-10 21:43:29 · 525 阅读 · 0 评论 -
Leetcode之Unique Paths II
题目 题目地址:https://leetcode.com/problems/unique-paths-ii/题意解析题目的意思还是求路径,不过路径中会存在阻碍,阻碍的位置将不能通过。这个是和前一个问题中不一样的地方,也因为这样,难度升高了一点点。求解定义最优解:最优解为从原点出发的所有路径。 定义最优解的值:这样的路径有多少个。递归式表示最优解的值:f[i,j] 表示从[0,0]出发到[i,j原创 2016-08-11 11:16:38 · 340 阅读 · 0 评论 -
Leetcode 之Search a 2D Matrix
题目https://leetcode.com/problems/search-a-2d-matrix/题意解析在二维数组中找一个数,这个二维数组满足2个特性同一行中的数字右边的比左边的大。下一行的第一个数比上一行的最后一个数大。求解应该找到这样的一个点,使得这样一个点和target数比较的时候如果小于只能是在其左边找,大于则只能在其下方找,想找这样的理由是根据二维数组的特性得到的。如果是从第一原创 2016-08-12 10:58:57 · 409 阅读 · 0 评论 -
Leetcode之SingleNumber I/II/III
Single Number I题解https://leetcode.com/problems/single-number/Single Number Given an array of integers, every element appears twice except for one. Find that single one.相同的数异或为0。 0和任何数异或都为这个数。 所以 全原创 2016-10-20 22:29:18 · 713 阅读 · 0 评论