自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(230)
  • 收藏
  • 关注

原创 SQL 语言分类-DDL、DML、DQL、DCL

SQL 语言分为四大类:数据查询语言 DQL,数据操纵语言 DML,数据定义语言 DDL,数据控制语言 DCL。数据查询语言 DQL(Data Query Language)基本结构是由 SELECT 子句,FROM 子句,WHERE 子句组成的查询块:SELECT <字段名表>FROM <表或视图名>WHERE <查询条件>数据操纵语言 DML(Data Manipulation Language)主要有三种形式:1)插入:INSERT2)更新

2021-11-22 10:36:01 453

原创 leetcode-525-连续数组

class Solution { public int findMaxLength(int[] nums) { // 把 0 变为 -1 for (int i = 0; i < nums.length; i++) { if (nums[i] == 0) nums[i] = -1; } // 记录前缀和到下标的映射 Map<Integer, Int.

2021-10-12 12:37:46 184

原创 leetcode-1371-每个元音包含偶数次的最长子字符串

时间复杂度 O(N)额外空间复杂度 O(1)class Solution { public int findTheLongestSubstring(String s) { // 记录结果,即下标差 int res = 0; // 记录截止遍历位,元音字符串 "aeiou" 每一种 bit mask 出现的最小下标 数组大小为 2^5 int seen[] = new int[32]; // 初始位置 bit ma..

2021-10-11 22:59:44 189

原创 leetcode-1542-找出最长的超赞子字符串

class Solution { public int longestAwesome(String s) { // 记录结果,即下标差 int res = 0; // 记录截止遍历位每一种 bit mask 出现的最小下标 数组大小为 2^10 int seen[] = new int[1024]; // 初始位置 bit mask 为 0,即空串 int mask = 0; int ..

2021-10-11 15:08:08 121

原创 leetcode-1915-最美子字符串的数目

class Solution { public long wonderfulSubstrings(String word) { // 记录结果 long res = 0; // 记录截止遍历位每一种 bit mask 出现的次数 数组大小为 2^10 long count[] = new long[1024]; // 初始位置 bit mask 为 0,即空串 int mask = 0; ..

2021-10-10 13:26:13 141

原创 排序算法-快速排序

时间复杂度 改良后选取随机数划分 O(N*logN) 改良前 O(N²)额外空间复杂度 改良后选取随机数划分 O(logN) 改良前 O(N)public static void quickSort(int[] arr) { if (arr == null || arr.length < 2) { return; } quickSort(arr, 0, arr.length - 1); } public static void quickSort(int[] arr, in

2021-10-08 14:46:01 66

原创 排序算法-归并排序

public static void mergeSort(int[] arr) { if (arr == null || arr.length < 2) { return; } process(arr, 0, arr.length - 1); } public static void process(int[] arr, int l, int r) { // base case if (l == r) { return; } int mid = (l +

2021-10-07 22:26:01 59

原创 Spark 提交任务流程

Spark 应用程序提交到 Yarn 环境中执行的时候,一般会有两种部署执行的方式:Client 和 Cluster。两种模式主要区别在于:Driver 程序的运行节点位置。Yarn Cluster 模式:Cluster 模式将用于监控和调度的 Driver 模块启动在 Yarn 集群资源中执行,一般用于实际生产环境。(1)任务提交后 Client 会和 ResourceManager 通讯申请启动 ApplicationMaster;(2)ResourceManage r分配 Container

2021-09-01 14:56:26 490

原创 YARN 工作机制

YARN 工作机制(1)MR 程序提交到客户端所在的节点;(2)YarnRunner 向 ResourceManager 申请一个 Application;(3)ResourceManager 将该应用程序的资源路径返回给 YarnRunner;(4)该程序将运行所需资源提交到 HDFS 上;(5)程序资源提交完毕后,申请运行 MRAppMaster;(6)ResourceManager 将用户的请求初始化成一个 Task;(7)其中一个 NodeManager 领取到 Task 任务;(.

2021-09-01 14:13:20 174

原创 HDFS 读写机制

HDFS 读数据流程(1)客户端通过 DistributedFileSystem 向NameNode 请求下载文件,NameNode 通过查询元数据,找到文件块所在的 DataNode 地址;(2)挑选一台 DataNode(就近原则,然后随机)服务器,请求读取数据;(3)DataNode 开始传输数据给客户端(从磁盘里面读取数据输入流,以Packet 为单位来做校验);(4)客户端以 Packet 为单位接收,先在本地缓存,然后写入目标文件;HDFS 写数据流程(1)客户端通过 Distri.

2021-09-01 13:57:31 87

原创 Hive 自定义函数分类

Hive 自定义函数分为 UDF、UDTF、UDAF.UDF (User-Defined-Function)即用户自定义函数,输入一行输出一行,一进一出;UDAF (User- Defined Aggregation Funcation)即用户自定义聚合函数,输入多行输出一行,多进一出;UDTF (User-Defined Table-Generating Functions)即用户自定义表生成函数,输入一行输出多行,一进多出;...

2021-07-06 11:38:52 249

原创 SQL 语句的执行顺序

SQL 语句的执行顺序以下方语句作为示例:(7) SELECT(8) DISTINCT <select_list>(1) FROM <left_table>(3) <join_type> JOIN <right_table>(2) ON <join_condition>(4) WHERE <where_condition>(5) GROUP BY <group_by_list>(.

2021-07-02 16:15:39 151

原创 Hadoop 3.X 和 2.X 的常用端口号和配置文件

Hadoop 常用端口号Hadoop 3.XHDFS NameNode 内部通信端口:8020/9000/9820HDFS NameNode HTTP UI:9870Yarn 查看任务执行端口:8088历史服务器通信端口:19888Hadoop 2.XHDFS NameNode 内部通信端口:8020/9000HDFS NameNode HTTP UI:50070Yarn 查看任务执行端口:8088历史服务器通信端口:19888Hadoop 常用配置文件Hadoop 3.X

2021-05-26 17:53:38 8921

原创 Linux-虚拟机centOS安装网络设置

创建虚拟机在配置网络连接时,有三种形式:桥连接Linux 可以和其他系统通信,但是可能造成 ip 冲突NAT网络地址转换方式,Linux 可以访问外网,不会造成 ip 冲突主机模式你的 Linux 是一个独立的主机,不能访问外网...

2021-05-24 10:47:33 57

原创 OLTP和OLAP

一、OLTP 和 OLAP的介绍数据处理大致可以分成两大类:联机事务处理 OLTP(on-line transaction processing)OLTP 是传统的关系型数据库的主要应用,主要是基本的、日常的事务处理,例如银行交易;OLTP 系统强调数据库内存效率,强调内存各种指标的命令率,强调绑定变量,强调并发操作等;联机分析处理 OLAP(On-Line Analytical Processing)是数据仓库系统的主要应用,支持复杂的分析操作,侧重决策支持,并且提供直观易懂的查

2021-05-20 16:55:15 163

原创 leetcode-354-俄罗斯套娃信封问题

class Solution { public int maxEnvelopes(int[][] envelopes) { // 排序 Arrays.sort(envelopes, new Comparator<int[]>() { // 按宽度升序排序,宽度一样时,按高度降序排序 // 以此保证在宽度相同的信封中最多只选取一个 public int compare(int[] a.

2021-04-29 18:11:46 79

原创 leetcode-53-最大子序和

class Solution { public int maxSubArray(int[] nums) { if (nums.length == 0) { return 0; } // dp[i] 即以 nums[i] 为结尾的最大连续子数组和 int dp[] = new int[nums.length]; // base case 第一个元素前面没有子数组 dp[0] = ..

2021-04-26 18:43:17 77

原创 leetcode-300-最长递增子序列

方法一:动态规划class Solution { public int lengthOfLIS(int[] nums) { // dp[i] 即以 nums[i] 这个数结尾的最长递增子序列的长度 int dp[] = new int[nums.length]; // base case // 以 nums[i] 这个数结尾的最长递增子序列至少包含自己本身 初始化为 1 Arrays.fill(dp, 1); .

2021-04-26 17:13:57 58

原创 leetcode-72-编辑距离

class Solution { public int minDistance(String word1, String word2) { int m = word1.length(); int n = word2.length(); // dp[i - 1][j - 1] 即 word1[0, i] 和 word2[0, j] 的最小编辑距离 // 设 word1[0] word2[0] 为空字符,表示其中一个字符串走完 .

2021-04-25 19:01:17 86

原创 leetcode-516-最长回文子序列

class Solution { public int longestPalindromeSubseq(String s) { int length = s.length(); // 初始化 dp 数组,i > j 时,不存在子序列,int 类型默认值为 0 // dp[i][j] 即在子串 s[i...j]中,最长回文子序列的长度 int[][] dp = new int[length][length]; /.

2021-04-25 11:12:31 53

原创 leetcode-931-下降路径最小和

class Solution { // 备忘录 int[][] memo; public int minFallingPathSum(int[][] matrix) { int n = matrix.length; int ans = Integer.MAX_VALUE; memo = new int[n][n]; // 初始化备忘录值为不存在的值 for (int[] array : memo) ..

2021-04-23 18:17:03 51

原创 leetcode-322-零钱兑换

// 动态规划 自底向上class Solution { public int coinChange(int[] coins, int amount) { int[] dp = new int[amount + 1]; // amount + 1 等同于赋值为无穷大 Arrays.fill(dp, amount + 1); // base case dp[0] = 0; // 外层遍历所有状态 ..

2021-04-22 18:06:17 43

原创 leetcode-509-斐波那契数

方法一:递归class Solution { public int fib(int n) { if (n == 0 || n == 1) { return n; } return fib(n - 1) + fib(n - 2); }}方法二:动态规划 自顶向下class Solution { // 题目要求 0=< n <= 30 int[] memo = new int[31];.

2021-04-22 17:07:35 57

原创 leetcode-316-去除重复字母-1081-不同字符的最小子序列

class Solution { public String removeDuplicateLetters(String s) { // 存储结果的栈 Stack<Character> stack = new Stack<>(); // 记录字符串中字符出现的次数 int[] count = new int[26]; for (int i = 0; i < s.length(); i++).

2021-04-21 17:11:58 59

原创 leetcode-283-移动零

class Solution { public void moveZeroes(int[] nums) { // 初始化快慢指针 int fast = 0; int slow = 0; // 得到不包含 0 的新数组,长度为 slow while (fast < nums.length) { if (nums[fast] != 0) { nums[slow].

2021-04-21 11:18:17 42

原创 leetcode-27-移除元素

class Solution { public int removeElement(int[] nums, int val) { if (nums.length == 0) { return 0; } // 初始化快慢指针 int fast = 0; int slow = 0; while (fast < nums.length) { if (nu..

2021-04-21 10:54:55 59

原创 leetcode-83-删除排序链表中的重复元素

/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) { this.val = val; this.next = next; } * ..

2021-04-21 10:25:10 48

原创 leetcode-26-删除有序数组中的重复项

class Solution { public int removeDuplicates(int[] nums) { if (nums.length == 0) { return 0; } // 初始化快慢指针 int slow = 0; int fast = 0; while (fast < nums.length) { if (nums[fas..

2021-04-21 10:11:27 61

原创 leetcode-398-随机数索引

class Solution { int[] nums; Random random; public Solution(int[] nums) { this.nums = nums; random = new Random(); } public int pick(int target) { int result = -1; int count = 1; for (.

2021-04-14 14:52:57 62

原创 leetcode-382-链表随机节点

/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) { this.val = val; this.next = next; } * }.

2021-04-14 11:30:02 73

原创 leetcode-710-黑名单中的随机数

class Solution { int count; HashMap<Integer, Integer> map; Random random; public Solution(int N, int[] blacklist) { random = new Random(); map = new HashMap<>(); for (int b : blacklist) { ..

2021-04-14 09:25:39 89

原创 leetcode-380- 常数时间插入、删除和获取随机元素

class RandomizedSet { // 存储元素 ArrayList<Integer> nums; // 存储元素和下标的映射关系 HashMap<Integer, Integer> valToIndex; // 随机数生成器 Random random; /** Initialize your data structure here. */ public RandomizedSet() { .

2021-04-13 17:48:03 60

原创 leetcode-3-无重复字符的最长子串

class Solution { public int lengthOfLongestSubstring(String s) { HashMap<Character, Integer> window = new HashMap<>(); int left = 0; int right = 0; int ans = 0; while(right < s.length()) { .

2021-04-13 15:46:02 40

原创 leetcode-438-找到字符串中所有字母异位词

class Solution { public List<Integer> findAnagrams(String s, String p) { HashMap<Character, Integer> need = new HashMap<>(); HashMap<Character, Integer> window = new HashMap<>(); for(c.

2021-04-13 08:55:48 65

原创 leetcode-567-字符串的排列

class Solution { public boolean checkInclusion(String s1, String s2) { HashMap<Character, Integer> need = new HashMap<>(); HashMap<Character, Integer> window = new HashMap<>(); for(char c : s1.t.

2021-04-12 17:49:50 51

原创 滑动窗口算法模板

滑动窗口算法模板 public void slidWindow(String s, String t) { HashMap<Character, Integer> need = new HashMap<>(); HashMap<Character, Integer> window = new HashMap<>(); for(char c : t.toCharArray()) {

2021-04-12 17:07:35 223

原创 leetcode-76-最小覆盖子串

class Solution { public String minWindow(String s, String t) { HashMap<Character, Integer> need = new HashMap<Character, Integer>(); HashMap<Character, Integer> window = new HashMap<Character, Integer>(); .

2021-04-12 17:00:56 60

原创 leetcode-344-反转字符串

class Solution { public void reverseString(char[] s) { int left = 0; int right = s.length - 1; while (left < right) { // 首尾交换 char temp = s[left]; s[left] = s[right]; s[right].

2021-04-09 11:30:55 51

原创 leetcode-1-两数之和

class Solution { public int[] twoSum(int[] nums, int target) { // 用 map 集合存储遍历过的元素,相比较两层循环遍历 // 时间复杂度由 O(N²)减少至 O(N) Map<Integer, Integer> map = new HashMap<Integer, Integer>(); for (int i = 0; i < nums.length;.

2021-04-09 11:18:34 38

原创 leetcode-167-两数之和 II - 输入有序数组

class Solution { public int[] twoSum(int[] numbers, int target) { int left = 0, right = numbers.length - 1; while (left <= right) { int sum = numbers[left] + numbers[right]; if (sum == target) { .

2021-04-09 10:39:08 47

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除