- 博客(202)
- 收藏
- 关注
![](https://csdnimg.cn/release/blogv2/dist/pc/img/listFixedTop.png)
原创 Java implements 与 extends总结
接口和抽象类的区别是什么? (1)接口只有定义,其方法不能在接口中实现,只有实现接口的类才能实现接口中定义的方法,而抽象类可以有方法的定义和实现 (2)接口需要实现(implements),但抽象类只能被继承(extends)。一个类可实现多个接口,但只能继承一个类,接口可借此实现多重继承。 (3)接口:“has-a”,继承:"is-a” (4)接口中成员默...
2018-05-24 18:49:50
1229
![](https://csdnimg.cn/release/blogv2/dist/pc/img/listFixedTop.png)
原创 abstract class 和 interface
使用abstract class的方式定义Demo抽象类的方式如下:abstract class Demo { abstract void method1(); abstract void method2(); …}使用interface的方式定义Demo抽象类的方式如下:interface Demo { void method1(); void meth...
2018-05-24 18:47:29
187
![](https://csdnimg.cn/release/blogv2/dist/pc/img/listFixedTop.png)
原创 Spark——Job逻辑执行图
Job逻辑执行图典型的Job逻辑执行图如上所示,经过下面四个步骤可以得到最终执行结果:1.从数据源(可以是本地file,内存数据结构, HDFS,HBase等)读取数据创建最初的RDD。2.对RDD进行一系列的transformation()操作,每一个transformation()会产生一个或多个包含不同类型RDD。3.对最后的final RDD进行action()操作,每个partition...
2018-04-18 20:46:35
2222
![](https://csdnimg.cn/release/blogv2/dist/pc/img/listFixedTop.png)
原创 Apache Spark——Shuffle 过程
如果我们将 map 端划分数据、持久化数据的过程称为 shuffle write,而将 reducer 读入数据、aggregate 数据的过程称为shuffle read。那么我们来了解一下,在spark中,如何将shuffle write和shuffle read加入到逻辑或者物理执行图中并高效实现。Shuffle write spark的shuffle通常使用HashMap对...
2018-04-13 17:26:52
334
转载 HDFS原理:HDFS 读写数据
HDFS 是做什么的? HDFS(Hadoop Distributed File System)是Hadoop项目的核心子项目,是分布式计算中数据存储管理的基础,是基于流数据模式访问和处理超大文件的需求而开发的,可以运行于廉价的商用服务器上。它所具有的高容错、高可靠性、高可扩展性、高获得性、高吞吐率等特征为海量数据提供了不怕故障的存储,为超大数据集(Large Data Set)的...
2018-07-10 18:00:22
2599
原创 Spark的排序原理
就比较新的Spark来说,题主要找的 RDD 层面的 sortByKey() 实现在Spark的 shuffle 当中的。 sortByKey() 采用的是tera-sort风格的实现,其自身包含一个使用range partitioning的shuffle操作。Stage 0:Sample。创建 RangePartitioner,先对输入的数据的key做sampling来估算key的...
2018-07-10 17:06:00
2212
原创 Spark-性能调优
常用参数配置--num-executors N--executor-cores N :这个参数决定了每个Executor进程并行执行task线程的能力。因为每个CPU core同一时间只能执行一个task线程。--driver-memory Ng --executor-memory Ng :每个Executor进程的内存设置4G~8G较为合适--conf spar...
2018-06-20 14:46:37
244
原创 690. Employee Importance
/*// Employee infoclass Employee {public: // It's the unique ID of each node. // unique id of this employee int id; // the importance value of this employee int importance; ...
2018-06-12 21:56:58
159
原创 652. Find Duplicate Subtrees
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */clas...
2018-06-12 21:56:21
151
原创 648. Replace Words
class Solution {public: string replaceWords(vector<string>& dict, string sentence) { string rep; if(sentence.size()==0) return rep; if(dict.size()==0...
2018-06-12 21:55:44
219
原创 599. Minimum Index Sum of Two Lists
class Solution {public: vector<string> findRestaurant(vector<string>& list1, vector<string>& list2) { vector<string> res; unordered_map<string,i...
2018-06-12 21:55:01
134
原创 594. Longest Harmonious Subsequence
class Solution {public: int findLHS(vector<int>& nums) { if(nums.empty()) return 0; map<int,int> map1; for(int i=0;i<nums.size();i++){ ...
2018-06-12 21:54:24
101
原创 581. Shortest Unsorted Continuous Subarray
class Solution {public: int findUnsortedSubarray(vector<int>& nums) { int n=nums.size(); int lo=0,hi=n-1; while(lo<n-1&&nums[lo]<=nums[lo+...
2018-06-12 21:53:50
121
原创 575. Distribute Candies
575. Distribute Candiesclass Solution {public: int distributeCandies(vector<int>& candies) { unordered_map<int,int> map; for(int i=0;i<candies.size();i++) ...
2018-06-12 21:53:02
113
原创 567. Permutation in String
class Solution {public: bool checkInclusion(string s1, string s2) { if(s2.size()<s1.size()){ return false; } vector<int> map1(26,0),map2(26,0); ...
2018-06-10 20:49:34
229
原创 554. Brick Wall
class Solution {public: int leastBricks(vector<vector<int>>& wall) { unordered_map<int,int> map; for(int i=0;i<wall.size();i++){ int sum=0; ...
2018-06-10 20:48:59
98
原创 547. Friend Circles
class Solution {public: int findCircleNum(vector<vector<int>>& M) { int res=0; vector<int> visited(M.size(),0); if(M.empty()) return...
2018-06-10 20:39:36
154
原创 542. 01 Matrix
class Solution {public: vector<vector<int>> updateMatrix(vector<vector<int>>& matrix) { queue<pair<int,int>> q; int dirx[4]={1,-1,0,0}; ...
2018-06-10 20:34:04
171
原创 535. Encode and Decode TinyURL
class Solution {public: vector<string> res; // Encodes a URL to a shortened URL. string encode(string longUrl) { res.push_back(longUrl); return "http://tinyurl.com/"...
2018-06-10 20:33:26
229
原创 525. Contiguous Array
class Solution {public: int findMaxLength(vector<int>& nums) { unordered_map<int,int> map; int sum=0,len=0; //把nums[]里所有的0改成-1,累加nums[i]并且记录索引index,当sum值再次...
2018-06-10 20:32:53
156
原创 524. Longest Word in Dictionary through Deleting
class Solution {public: string findLongestWord(string s, vector<string>& d) { string str={}; if(s.empty() || d.empty()){ return str; } for(i...
2018-06-10 20:32:18
158
原创 515. Find Largest Value in Each Tree Row
class Solution {public: vector<int> largestValues(TreeNode* root) { vector<int> res; if(root==NULL) return res; queue<TreeNode*> q; q...
2018-06-10 20:31:42
107
原创 513. Find Bottom Left Tree Value
class Solution {public: int findBottomLeftValue(TreeNode* root) { int res; queue<TreeNode*> q; TreeNode* left; if(root) q.push(root); whi...
2018-06-10 20:24:01
95
原创 503. Next Greater Element II
class Solution {public: vector<int> nextGreaterElements(vector<int>& nums) { unordered_map<int,int> great;//序号,更大值 vector<int> res; stack<in...
2018-06-10 20:23:19
78
原创 500. Keyboard Row
class Solution {public: vector<string> findWords(vector<string>& words) { vector<string> res; unordered_set <char> row1 = { 'q','Q','w','W','e...
2018-06-09 16:42:57
90
原创 496. Next Greater Element I
class Solution {public: vector<int> nextGreaterElement(vector<int>& findNums, vector<int>& nums) { stack<int> s; unordered_map<int,int> great...
2018-06-09 16:42:25
96
原创 494. Target Sum
class Solution {public: int res=0; int findTargetSumWays(vector<int>& nums, int S) { int res=0; res+=helper(nums,0,0,S); return res; } int helper(vec...
2018-06-09 16:40:50
110
原创 491. Increasing Subsequences
class Solution {public: vector<vector<int>> findSubsequences(vector<int>& nums) { vector<vector<int>> res; vector<int> sub; if(nums...
2018-06-09 16:40:17
90
原创 485. Max Consecutive Ones
class Solution {public: int findMaxConsecutiveOnes(vector<int>& nums) { int n = nums.size(); int maxlen=0,len=0; for(int i=0;i<n;i++){ if(nums[i]=...
2018-06-09 16:39:46
182
原创 474. Ones and Zeroes
class Solution {public: int findMaxForm(vector<string>& strs, int m, int n) { if(strs.empty()) return 0; vector<vector<int>> form(m+1,vector<i...
2018-06-09 16:39:12
101
原创 473. Matchsticks to Square
class Solution {public: bool makesquare(vector<int>& nums) { if(nums.empty()||nums.size()==0) return false; int length=0; vector<int> sum(4,0);...
2018-06-09 16:38:22
116
原创 451. Sort Characters By Frequency
class Solution {public: string frequencySort(string s) { int counts[256] = {0}; for (char ch : s) ++counts[ch]; sort(s.begin(), s.end(), [&](char a, char b...
2018-06-09 16:37:30
108
原创 448. Find All Numbers Disappeared in an Array
class Solution {public: vector<int> findDisappearedNumbers(vector<int>& nums) { int n = nums.size(); for(int i=0;i<n;i++){ int m=abs(nums[i])-1; ...
2018-06-09 16:36:30
82
原创 445. Add Two Numbers II
class Solution {public: ListNode *addTwoNumbers(ListNode *l1, ListNode *l2) { // write your code here if(l1 == NULL){ return l2; } if(l2 == NULL){ ...
2018-06-08 16:11:46
101
原创 442. Find All Duplicates in an Array
class Solution {public: vector<int> findDuplicates(vector<int>& nums) { vector<int> res; int n=nums.size(); //int tra,i=0; int i=0; w...
2018-06-07 23:52:32
90
原创 441. Arranging Coins
class Solution {public: int arrangeCoins(int n) { /* int row=0,sum=0; while(sum+row+1<=n){ row++; sum+=row; } return row; ...
2018-06-07 23:51:56
74
原创 438. Find All Anagrams in a String
class Solution {public: vector<int> findAnagrams(string s, string p) { vector<int> res; if(s.empty()) return res; vector<int> map1(26,0); ...
2018-06-07 23:51:20
74
原创 417. Pacific Atlantic Water Flow
class Solution {public: int dirx[4]={1,-1,0,0}; int diry[4]={0,0,1,-1}; vector<pair<int, int>> pacificAtlantic(vector<vector<int>>& matrix) { vector<...
2018-06-07 23:50:38
105
原创 409. Longest Palindrome
class Solution {public: int longestPalindrome(string s) { if(s.empty()) return 0; unordered_map<char,int> map; int res=0,flag=0; for(int i=0;i<...
2018-06-07 23:49:25
79
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人