03 2017 档案

摘要:Given an array of strings, group anagrams together. For example, given: , Return: [ ["ate", "eat","tea"], ["nat","tan"], ["bat"] ] Note: All inputs wi 阅读全文
posted @ 2017-03-31 20:39 aiterator 阅读(115) 评论(0) 推荐(0) 编辑
摘要:You are given an 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in place? 水题 C++ class Solu 阅读全文
posted @ 2017-03-31 19:52 aiterator 阅读(76) 评论(0) 推荐(0) 编辑
摘要:Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, have the following unique permutati 阅读全文
posted @ 2017-03-31 19:21 aiterator 阅读(86) 评论(0) 推荐(0) 编辑
摘要:Given a collection of distinct numbers, return all possible permutations. For example, have the following permutations: [ [1,2,3], [1,3,2], [2,1,3], [ 阅读全文
posted @ 2017-03-31 18:26 aiterator 阅读(101) 评论(0) 推荐(0) 编辑
摘要:Given an array of non negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文
posted @ 2017-03-31 16:13 aiterator 阅读(161) 评论(0) 推荐(0) 编辑
摘要:自己终究只是普通人 帮别人写一个大作业,发现自己真的什么都不会。 每天朝九晚五的在机房,人际交流很少,上课也不听讲,只想学习一些自己感兴趣的东西,以为慢慢学习总会有收获的,积少成多,总会变厉害的。 今天才发现,自己真的好垃圾。 终究只是普通人。。 还是做一个不太平凡的普通人吧!就算垃圾,相信慢慢学习 阅读全文
posted @ 2017-03-30 22:51 aiterator 阅读(97) 评论(0) 推荐(0) 编辑
摘要:Implement wildcard pattern matching with support for '?' and ' '. '?' Matches any single character. ' ' Matches any sequence of characters (including 阅读全文
posted @ 2017-03-29 20:14 aiterator 阅读(122) 评论(0) 推荐(0) 编辑
摘要:Given two non negative integers and represented as strings, return the product of and . Note: + 1.The length of both and is &arr) { for(int i=str.size 阅读全文
posted @ 2017-03-28 11:33 aiterator 阅读(157) 评论(0) 推荐(0) 编辑
摘要:Given non negative integers representing an elevation map where the width of each bar is , compute how much water it is able to trap after raining. Fo 阅读全文
posted @ 2017-03-27 21:41 aiterator 阅读(96) 评论(0) 推荐(0) 编辑
摘要:Given an unsorted integer array, find the first missing positive integer. For example, Given return , and return . Your algorithm should run in time a 阅读全文
posted @ 2017-03-27 21:10 aiterator 阅读(169) 评论(0) 推荐(0) 编辑
摘要:时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 H国正在进行一项持续N周的填海造岛工程。整片工程海域可以被看作是1000x1000的网格。 每周都有一块1x1的单位方格海域被填成陆地。如果我们将连成一片的陆地(一块单位方格与它上下左右4个单位方格是相连的)视为岛屿,H国 阅读全文
posted @ 2017-03-26 17:12 aiterator 阅读(194) 评论(0) 推荐(0) 编辑
摘要:时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi现在有n个物品,每个物品都有一个价值。并且这n个物品总共有m个不同的属性,每个物品都具有其中若干属性。 小Ho要从中选出若干物品,满足每个属性都正好有奇数个物品拥有,且被选出的物品价值总和最大。你能帮助小Ho完成任务 阅读全文
posted @ 2017-03-26 17:04 aiterator 阅读(278) 评论(0) 推荐(0) 编辑
摘要:时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 如果一个字符串恰好包含2个'h'、1个'i'和1个'o',我们就称这个字符串是hiho字符串。 例如"oihateher"、"hugeinputhugeoutput"都是hiho字符串。 现在给定一个只包含小写字母的字符串 阅读全文
posted @ 2017-03-26 16:51 aiterator 阅读(302) 评论(0) 推荐(0) 编辑
摘要:Given a collection of candidate numbers ( C ) and a target number ( T ), find all unique combinations in C where the candidate numbers sums to T . Eac 阅读全文
posted @ 2017-03-25 00:08 aiterator 阅读(117) 评论(0) 推荐(0) 编辑
摘要:Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums 阅读全文
posted @ 2017-03-23 19:03 aiterator 阅读(135) 评论(0) 推荐(0) 编辑
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character . You may assume that there will be on 阅读全文
posted @ 2017-03-22 09:05 aiterator 阅读(109) 评论(0) 推荐(0) 编辑
摘要:Determine if a Sudoku is valid, according to: Sudoku Puzzles The Rules. The Sudoku board could be partially filled, where empty cells are filled with 阅读全文
posted @ 2017-03-21 22:54 aiterator 阅读(106) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime complexi 阅读全文
posted @ 2017-03-20 22:45 aiterator 阅读(77) 评论(0) 推荐(0) 编辑
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You a 阅读全文
posted @ 2017-03-20 22:44 aiterator 阅读(80) 评论(0) 推荐(0) 编辑
摘要:Given n pairs of parentheses, write a function to generate all combinations of well formed parentheses. For example, given n = 3, a solution set is: [ 阅读全文
posted @ 2017-03-20 22:43 aiterator 阅读(81) 评论(0) 推荐(0) 编辑
摘要:Given a string containing just the characters '(' and ')', find the length of the longest valid (well formed) parentheses substring. For "(()", the lo 阅读全文
posted @ 2017-03-20 15:19 aiterator 阅读(109) 评论(0) 推荐(0) 编辑
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib 阅读全文
posted @ 2017-03-19 20:20 aiterator 阅读(102) 评论(0) 推荐(0) 编辑
摘要:Implement regular expression matching with support for '.' and ' '. '.' Matches any single character. ' ' Matches zero or more of the preceding elemen 阅读全文
posted @ 2017-03-18 10:12 aiterator 阅读(90) 评论(0) 推荐(0) 编辑
摘要:You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a conca 阅读全文
posted @ 2017-03-17 16:11 aiterator 阅读(124) 评论(0) 推荐(0) 编辑
摘要:题目链接: + 题目大意: + 有一些木棍,木棍两端有不同的颜色; + 两个木棍能够排列到一块,当且仅当两个木棍相邻端点颜色一样; + 问这些木棍能否全部链接到一块; 解题思路: + 首先,可以将每一个颜色,看做是一个点; + 木棍就可以看做为两个颜色之间的一条边; + 然后就可以组成一个图; + 阅读全文
posted @ 2017-03-17 13:48 aiterator 阅读(132) 评论(0) 推荐(0) 编辑
摘要:题目链接: + 题目大意: + 一个NxN矩阵,有一些障碍在矩阵中; + 消除障碍,一次可以消除一行或者一列; + 问最小次数 解题思路: + 可以将每一行,每一列看做一个端点; + 障碍看做两个端点之间的边, 那么NxN矩阵就转化为了一个无向图。 + 最后只求最小点覆盖,即为答案 + 最小点覆盖 阅读全文
posted @ 2017-03-17 08:50 aiterator 阅读(105) 评论(0) 推荐(0) 编辑
摘要: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 and is less than or equal to 阅读全文
posted @ 2017-03-16 16:27 aiterator 阅读(104) 评论(0) 推荐(0) 编辑
摘要:简单dp 假设dp[i]为前i个字符能够最小去除dp[i]个元素,剩下的可以由字符串组成。所以可知 dp[i] = min(dp[i], dp[i j] + i j len); 其中len为[i j,i]区间, 存在的字符串的长度。 但是由于,对于每一个i,都要向前面找j。 这样就会很麻烦。 那么只 阅读全文
posted @ 2017-03-14 19:25 aiterator 阅读(141) 评论(0) 推荐(0) 编辑
摘要:刚看到这个题目, 还有为几个if,else就可以了, 然后就开始敲了, 后来发现并没有那么简单。 参考题解: C++ include using namespace std; int solve(long long a, long long b, long long k) { if(a == 0) 阅读全文
posted @ 2017-03-12 21:13 aiterator 阅读(308) 评论(0) 推荐(0) 编辑
摘要:+ 一个数字n, 问从1到n中, 0 9总共出现了多少次? + 对于一个数字n, 若此时1 n中,0 9的个数分别在 ans 数组中存在, 那么对于 res = n 10+9的这个数字,在1 res中,0 9的个数分别为 ans[i] 10 + n + (i != 1), 0 1. 其中ans[i] 阅读全文
posted @ 2017-03-12 21:05 aiterator 阅读(119) 评论(0) 推荐(0) 编辑
摘要:将所有起始不为空的链表的 头部存入优先队列,然后每次从优先队列里面取出值最小的, 并判断它的下一个节点是否为空,如果不为空,将下一个节点也存入优先队列。 阅读全文
posted @ 2017-03-09 15:28 aiterator 阅读(63) 评论(0) 推荐(0) 编辑
摘要:题目大意就是给你一个数组,从里面找出三个数字,使这三个数字的和为0。 通过先排序,枚举第一个数字a,然后可以通过前后夹逼的方法,找到两个数字b,c。使b + c = a。那么这三个即符合题意,需要注意的是,去除重复元素。自己写的用set,感觉有点蠢。。。, 时间复杂度有点高,300多ms过的。 后来 阅读全文
posted @ 2017-03-08 21:22 aiterator 阅读(80) 评论(0) 推荐(0) 编辑
摘要:将(1 3999)的阿拉伯数字转化为罗马数字。 罗马数字中,I、V、X、L、C、D和M,分别表示1、5、10、50、100、500和1000。 只需要注意4和9这两个数字就可以了 class Solution { public: string intToRoman(int num) { string 阅读全文
posted @ 2017-03-07 20:18 aiterator 阅读(99) 评论(0) 推荐(0) 编辑
摘要:题目意思就是说有n块木板,对于第i个木板长度应该是a[i],竖直放在x坐标轴上,现在为任选两个木板,求最大能盛水的体积。 两块木板能盛水的多少取决与短的木板的长度。所以不需要枚举所有可能的(i , j)(i a[j], 那么使 j 向前挪动,才可能使总体积变大,因为无论i向后挪动,还是j向前挪动,都 阅读全文
posted @ 2017-03-07 19:46 aiterator 阅读(90) 评论(0) 推荐(0) 编辑
摘要:LeetCode 8. String to Integer (atoi) 标签(空格分隔): LeetCode 题目大意就是给你一个字符串,使它转化成数字 去除前导0 判断起始位置为正负号,数字或者其他字符。 如果是数字,使以前的数字乘以10加上现在的数字。不是数字直接返回值就可以了 阅读全文
posted @ 2017-03-07 18:58 aiterator 阅读(97) 评论(0) 推荐(0) 编辑
摘要:水题 class Solution { public: string convert(string s, int numRows) { if(numRows 阅读全文
posted @ 2017-03-05 14:02 aiterator 阅读(88) 评论(0) 推荐(0) 编辑
摘要:裸的manager算法。 代码如下: 阅读全文
posted @ 2017-03-04 17:09 aiterator 阅读(122) 评论(0) 推荐(0) 编辑
摘要:水题 class Solution { public: double findMedianSortedArrays(vector& nums1, vector& nums2) { vector nums3; int bg1 = 0, bg2 = 0; while(bg1 = nums2[bg2]) 阅读全文
posted @ 2017-03-04 11:36 aiterator 阅读(102) 评论(0) 推荐(0) 编辑
摘要:题目大意就是找出字符串中最长的一个字串, 这个字串中任意两个元素都不一样。 尺取法的模版题 阅读全文
posted @ 2017-03-04 11:14 aiterator 阅读(95) 评论(0) 推荐(0) 编辑
摘要:计数排序,记下0,1,2的个数,然后在赋值给vector。这样数组循环了两遍不符合题意 class Solution { public: void sortColors(vector& nums) { int b = 0, e = nums.size() 1; int l = b, r = e; w 阅读全文
posted @ 2017-03-03 21:10 aiterator 阅读(102) 评论(0) 推荐(0) 编辑
摘要:先声明一个链表指针l1,在声明一个链表指针l2, 用l1来维护他们的和,l2记录l1的初始位置。 阅读全文
posted @ 2017-03-03 13:47 aiterator 阅读(95) 评论(0) 推荐(0) 编辑
摘要:两种方法 先排序,然后前后夹逼(复杂度n log(n))。 存在unordered_map,然后直接find.(复杂度n) 阅读全文
posted @ 2017-03-03 09:29 aiterator 阅读(109) 评论(0) 推荐(0) 编辑
摘要:题目链接 题目大意 有m个关系, 每个关系是两个城市相距的距离,求把这些城市全部连接起来的最小距离。 解题思路 典型的最小生成树 代码如下 kruskal算法 include using namespace std; const int N = 57; const int INF = 0x3f3f3 阅读全文
posted @ 2017-03-03 09:08 aiterator 阅读(164) 评论(0) 推荐(0) 编辑
摘要:题目链接 题目大意 初始有一个矩阵,代表从i到j需要花费的电缆数,现在问如果将从1到n全部连接起来,最多剩下多少电缆 解题思路 最小生成树模版题 代码如下 prime算法 C++ include using namespace std; const int N = 57; const int INF 阅读全文
posted @ 2017-03-02 20:07 aiterator 阅读(179) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示