- 博客(11)
- 收藏
- 关注
原创 LeetCode之4---Median of Two Sorted Arrays
题目: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).大意: 两个已
2016-03-31 23:53:05 580
原创 LeetCode之300—-Longest Increasing Subsequence
题目:Given an unsorted array of integers, find the length of longest increasing subsequence.For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The longest increasing subsequence is [2, 3, 7, 101
2016-03-30 19:03:02 761
原创 数组中位数
题目:将两个等长有序数组的中位数,要求时间复杂度为O(logn)。思路:大体思想是:比较两个数组的中位数 (1)、如果相同则该值就是中位数 (2)、如果num1 则中位数位于num1的后半部分或num2的前半部分 (3)、如果num1 > num2则中位数位于num1的前半部分或num2的后半部分 (4)、一直执行(2)和(3)直到数
2016-03-29 22:08:58 1014
原创 链表中一些有趣的小题目总结
1、单链表中间结点问:如何快速查找定位到一条单链表的中间结点?答:(1)、可以将链表中的所有结点遍历一遍得到总个数,再查找到中间结点(这不废话嘛,这么low的答案就不拉出来献丑了=、=)(2)、可以使用快慢指针法,一个指针一倍速率遍历,另一个指针两倍速率遍历链表,当第一个走到末尾时第二个则刚好在中间位置代码:NODE *Search(NODE *pHead)
2016-03-28 23:45:09 785
原创 LeetCode之3---Longest Substring Without Repeating Characters
题目: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is
2016-03-28 23:32:35 540
原创 LeetCode之2— Add Two Numbers
题目:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it
2016-03-27 15:55:11 551
原创 TCP/IP初探
目前互联网上使用的主流协议族就是TCP/IP协议族,它是一个分层、多协议的通信体系。TCP/IP协议族是一个四层协议系统,自低向上分别是数据链路层、网络层、传输层和应用层。下层协议为上层协议提供服务。 数据链路层:实现了网卡接口的网络驱动程序,以处理数据在物理媒介上的传输,数据链路层的相关协议隐藏了不同物理网络上的不同电气特性,为上层协议提供了一个通用的接口。数据链
2016-03-27 15:11:14 611
原创 LeetCode之1—-Two Sum
题目:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution.题目大意:给定
2016-03-27 15:08:31 716
原创 LeetCode之338—-Counting Bits
最近上算法课上的有点心塞,所以感觉应该刷刷题来见见世面了,所以选择了LeetCode来做一点题目。LeetCode之338:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary
2016-03-26 15:31:03 618
原创 中缀表达式求值
所谓表达式的求值就是从键盘上输入一个四则运算表达式按下Enter后在屏幕上输出表达式的结果。表达式的求值在计算机的应用中非常广泛,例如编译器中对所写的程序表达式的编译等。它也是数据结构课程中栈这一章节中非常重要的一个算法,通过实现这个算法可以更好的掌握和理解栈的相关操作。中缀表达式是指运算符在运算数的中间,计算中缀表达式时需要用到两个栈:数字栈和运算符栈。在整个中缀表达式求值的过程中主要涉
2016-03-26 13:24:26 4228 2
原创 图算法之最小生成树(Kruskal)
所谓最小生成树是指:给定一个无向图G={V,E},用集合{u,v}∈E表示从u到v的边,w(u,v)表示从u到v的权值,若{u,v}集合中所有元素权值之和最小且没有构成回路,则称集合{u,v}为该图的最小生成树。举个例子,如下图所示的连通图中,其中的一个最小生成树为边:(A,C)、(A,D)、(D,B)、(D,F)、(B,E)、(E、G)组成的树。最小生成树在现实生活中的应
2016-03-26 13:15:55 1079
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人