上一页 1 2 3 4 5 6 ··· 13 下一页
摘要: A - Rewards水题,把a累加,然后向上取整(double)a/5,把b累加,然后向上取整(double)b/10,然后判断a+b是不是大于n即可#include #include #include #include using namespace std;int main(){ dou... 阅读全文
posted @ 2014-07-18 09:55 OpenSoucre 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 数据结构应用场景示例哈希表要求所有键值对放入内存,查找可以在常数时间内完成。l 提取某日志访问百度次数最多的IPl 统计不同电话号码的个数堆插入和调整需要O(logn)时间,n为堆元素的个数,而获取堆顶元素只需要常数时间。l 求出海量数据前K大的数l 求海量数据流的中位数BitMap通常记录整数出现... 阅读全文
posted @ 2014-07-17 11:09 OpenSoucre 阅读(523) 评论(0) 推荐(0) 编辑
摘要: Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"Corner Cases:Did you con... 阅读全文
posted @ 2014-07-15 22:04 OpenSoucre 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space i... 阅读全文
posted @ 2014-07-15 20:40 OpenSoucre 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 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).For example,S="ADOBECODEBA... 阅读全文
posted @ 2014-07-15 12:13 OpenSoucre 阅读(233) 评论(0) 推荐(0) 编辑
摘要: A - DZY Loves Hash水题,开辟一个数组即可#include #include #include #include using namespace std;int main(){ int p,n; cin >> p >> n; vector buckets(302,f... 阅读全文
posted @ 2014-07-14 15:17 OpenSoucre 阅读(323) 评论(0) 推荐(0) 编辑
摘要: There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requi... 阅读全文
posted @ 2014-07-08 22:17 OpenSoucre 阅读(352) 评论(0) 推荐(0) 编辑
摘要: Given two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Only one letter can be ... 阅读全文
posted @ 2014-07-08 21:46 OpenSoucre 阅读(210) 评论(0) 推荐(0) 编辑
摘要: A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ... 阅读全文
posted @ 2014-07-08 21:04 OpenSoucre 阅读(236) 评论(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 @ 2014-07-07 21:26 OpenSoucre 阅读(158) 评论(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 @ 2014-07-07 20:59 OpenSoucre 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 先生成nXm的BW棋盘BWBWBWBWWBWBWBWBBWBWBWBWWBWBWBWB类似上面交替变换然后将输入为’-’的地方替换成‘-’即可#include #include #include #include using namespace std;int main(){ int n,m;... 阅读全文
posted @ 2014-07-06 23:22 OpenSoucre 阅读(277) 评论(0) 推荐(0) 编辑
摘要: Given a collection of numbers, return all possible permutations.For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,... 阅读全文
posted @ 2014-07-05 21:22 OpenSoucre 阅读(150) 评论(0) 推荐(0) 编辑
摘要: Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.class Solution {public: ... 阅读全文
posted @ 2014-07-05 21:02 OpenSoucre 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinc... 阅读全文
posted @ 2014-07-05 20:42 OpenSoucre 阅读(159) 评论(0) 推荐(0) 编辑
摘要: Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjace... 阅读全文
posted @ 2014-07-05 18:35 OpenSoucre 阅读(190) 评论(0) 推荐(0) 编辑
摘要: Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially... 阅读全文
posted @ 2014-07-05 17:32 OpenSoucre 阅读(171) 评论(0) 推荐(0) 编辑
摘要: Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18].题目的意思是将相交得区间合并... 阅读全文
posted @ 2014-07-05 16:31 OpenSoucre 阅读(126) 评论(0) 推荐(0) 编辑
摘要: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Pana... 阅读全文
posted @ 2014-07-04 23:32 OpenSoucre 阅读(150) 评论(0) 推荐(0) 编辑
摘要: Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.题目的意思是:给出一组字符串,按组返回拥有相同变位词的字符串解题思路是: ... 阅读全文
posted @ 2014-07-04 21:40 OpenSoucre 阅读(118) 评论(0) 推荐(0) 编辑
摘要: You are given a string,S, and a list of words,L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenati... 阅读全文
posted @ 2014-07-04 18:26 OpenSoucre 阅读(313) 评论(0) 推荐(0) 编辑
摘要: Divide two integers without using multiplication, division and mod operator.不用乘、除、求余操作,返回两整数相除的结果,结果也是整数。假设除数是2,相除的商就是被除数二进制表示向右移动一位。假设被除数是a,除数是b,因为不知... 阅读全文
posted @ 2014-07-04 17:54 OpenSoucre 阅读(146) 评论(0) 推荐(0) 编辑
摘要: Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You have the fol... 阅读全文
posted @ 2014-07-04 17:03 OpenSoucre 阅读(165) 评论(0) 推荐(0) 编辑
摘要: Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa... 阅读全文
posted @ 2014-07-04 13:06 OpenSoucre 阅读(194) 评论(0) 推荐(0) 编辑
摘要: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo... 阅读全文
posted @ 2014-07-04 12:04 OpenSoucre 阅读(232) 评论(0) 推荐(0) 编辑
摘要: Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ... 阅读全文
posted @ 2014-07-04 11:44 OpenSoucre 阅读(241) 评论(0) 推荐(0) 编辑
摘要: Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m... 阅读全文
posted @ 2014-07-04 11:18 OpenSoucre 阅读(204) 评论(0) 推荐(0) 编辑
摘要: Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Elemen... 阅读全文
posted @ 2014-07-04 10:55 OpenSoucre 阅读(173) 评论(0) 推荐(0) 编辑
摘要: There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requi... 阅读全文
posted @ 2014-07-04 10:32 OpenSoucre 阅读(122) 评论(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 maximu... 阅读全文
posted @ 2014-07-04 10:13 OpenSoucre 阅读(203) 评论(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 maximu... 阅读全文
posted @ 2014-07-04 09:56 OpenSoucre 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 题目的意思就是将十进制转换成格雷码首先将二进制转换成格雷码根据此图可以看出二进制的第i和第i+1位异或为格雷码的第i+1位,对于给定的十进制数x,其(x>>1)相当于二进制向右移动一位将 x^(x>>1)刚好能按照上述方式完成异或,故结果为x的格雷码class Solution {public: ... 阅读全文
posted @ 2014-07-03 22:29 OpenSoucre 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Givennnon-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.Fo... 阅读全文
posted @ 2014-07-03 21:47 OpenSoucre 阅读(180) 评论(0) 推荐(0) 编辑
摘要: Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the orig... 阅读全文
posted @ 2014-07-03 20:42 OpenSoucre 阅读(205) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o... 阅读全文
posted @ 2014-07-03 20:14 OpenSoucre 阅读(146) 评论(0) 推荐(0) 编辑
摘要: Validate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>trueNote:It is intended for the problem stat... 阅读全文
posted @ 2014-07-03 18:05 OpenSoucre 阅读(314) 评论(0) 推荐(0) 编辑
摘要: Given an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Your algorithm should ru... 阅读全文
posted @ 2014-07-03 17:35 OpenSoucre 阅读(204) 评论(0) 推荐(0) 编辑
摘要: Write a function to find the longest common prefix string amongst an array of strings.class Solution {public: string longestCommonPrefix(vector &st... 阅读全文
posted @ 2014-07-03 17:19 OpenSoucre 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 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 ord... 阅读全文
posted @ 2014-07-03 16:59 OpenSoucre 阅读(174) 评论(0) 推荐(0) 编辑
摘要: Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.class Solution... 阅读全文
posted @ 2014-07-02 21:45 OpenSoucre 阅读(247) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 13 下一页