上一页 1 2 3 4 5 6 7 ··· 29 下一页
摘要: 图常用的存储方法又邻接表表示法以及邻接矩阵表示法,邻接表适合稀疏矩阵的存储,但是缺点是稍微复杂一点,并且插入操作或者说更新图的操作实际上是比较复杂的,而邻接矩阵更加简单,再存储密集矩阵的时候更加合适,下面使用c++实现一个简单的邻接矩阵。 由于图一般简单的分为几种:1. 无向图 2.有向图 3... 阅读全文
posted @ 2016-01-15 16:04 eversliver 阅读(1870) 评论(0) 推荐(0) 编辑
摘要: Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to... 阅读全文
posted @ 2016-01-15 13:07 eversliver 阅读(308) 评论(0) 推荐(0) 编辑
摘要: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-... 阅读全文
posted @ 2016-01-14 21:24 eversliver 阅读(284) 评论(0) 推荐(0) 编辑
摘要: Implement a trie withinsert,search, andstartsWithmethods.实现字典树,前面好像有道题做过类似的东西,代码如下: 1 class TrieNode { 2 public: 3 // Initialize your data structu... 阅读全文
posted @ 2016-01-13 16:30 eversliver 阅读(400) 评论(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]. 看起来感觉不像har 阅读全文
posted @ 2016-01-12 22:37 eversliver 阅读(333) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.由于对于这个二叉搜索树的要求是其必须是其必须是平衡的,所以应该使用递归。首先找到二... 阅读全文
posted @ 2016-01-11 13:05 eversliver 阅读(226) 评论(0) 推荐(0) 编辑
摘要: Given an Iterator class interface with methods:next()andhasNext(), design and implement a PeekingIterator that support thepeek()operation -- it essent... 阅读全文
posted @ 2016-01-07 22:14 eversliver 阅读(238) 评论(0) 推荐(0) 编辑
摘要: Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two... 阅读全文
posted @ 2016-01-07 17:54 eversliver 阅读(264) 评论(0) 推荐(0) 编辑
摘要: Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top()... 阅读全文
posted @ 2016-01-06 22:25 eversliver 阅读(235) 评论(0) 推荐(0) 编辑
摘要: Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t... 阅读全文
posted @ 2016-01-06 19:01 eversliver 阅读(216) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 29 下一页