- 博客(9)
- 收藏
- 关注
原创 Spark入门小结
SparkRDD(resilient distributed dataset):RDD是Spark对分布式数据和计算的基本抽象。spark会自动将函数发到各个执行器节点上,这样,你就可以在单一的驱动器程序中编程,并且让代码自动运行在多个节点上。A.快速入门1.创建方式:1.1 读取外部数据集1.2 在驱动器程序中对一个集合进行并行化2.RDD支持两种操作2.1 转化操作 ...
2019-03-30 17:30:01
153
原创 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)). 提到log(m),自然会想到二分查找。 本题相比一个
2017-02-24 14:52:00
229
原创 LinkedList源码解析(JDK1.7)
LinkedList底层使用双向链表数据结构,没有容量大小限制,下面进入源码解析:public class LinkedList<E> extends AbstractSequentialList<E> implements List<E>, Deque<E>, Cloneable, java.io.Serializable通过上面这段类的声明: 实现了List接口,可以进行队列操
2017-02-22 17:03:42
329
原创 26.Ugly Number2
Write a program to find the n-th ugly number.思路:一开始,我考虑的是遍历查找,逐个判断是否为丑数,果断耗时太长。//TLE,1600th cost 17.148s public static int nthUglyNumber(int n){ if(n <= 0){ return 0; } int count = 0
2017-02-17 17:50:55
267
原创 263.Ugly Number
@target Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not
2017-02-17 17:26:22
190
原创 204:Count Primers
target:Count the number of prime numbers less than a non-negative number n我第一次编写的解决代码,时间复杂度是O(n2),在40多万时就挂了。 //O(n2),cost too much time public int simplecountPrimes(int n) { int num = 0; for
2017-02-16 17:09:45
185
原创 513:find bottom left tree value
思考:本题比较简单,是运用广度优先算法,通过队列存储同一深度元素。 public int findBottleLeftValue(TreeNode root){ Queue q = new LinkedList(); q.offer(root); int result = 0; while (!q.isEmpty()) { int size = q.size();
2017-02-16 16:48:46
294
原创 8:String to Integer
思考:本题的难点体现在对各种情况能否全部覆盖,已经对细节的把握上。可能出现的各种特殊情况:1.null or empty input 2.+ & - 3.white space 4.max and min of integerpublic class atoi { public int luoAtoi(String str){ if(str==n
2017-02-16 16:07:19
394
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人