- 博客(28)
- 资源 (9)
- 收藏
- 关注
原创 力扣---2020.7.13
350. 两个数组的交集 IIclass Solution { public int[] intersect(int[] nums1, int[] nums2) { Map<Integer,Integer> map = new HashMap<>(); for(int num : nums1){ map.put(num,map.getOrDefault(num,0)+1); } List
2020-09-28 20:55:40 149
原创 力扣---2020.7.12
174. 地下城游戏class Solution { public int calculateMinimumHP(int[][] dungeon) { int[][] dp = new int[dungeon.length][dungeon[0].length]; int res = 0; for(int i=dungeon.length-1;i>=0;i--){ for(int j=dungeon[0].length-
2020-09-27 00:07:49 130
原创 机器学习常用算法分享
文章目录KNN原理优缺点逻辑斯蒂函数原理优缺点决策树原理优缺点朴素贝叶斯支持向量机自适应提升算法KNNK-近邻算法(k-Nearest Neighbor,KNN)采用测量不同特征值之间的距离方法进行分类。原理已知的数据分为两类:一类是蓝色的正方形,一类是红色的三角形。绿色圆形是待分类的数据。当K=3和K=5时,得到的分类结果不同。KNN本质是基于一种数据统计的方法。度量空间中点之间的距离,常见的曼哈顿距离计算,欧式距离计算等等。不过通常KNN算法中使用的是欧式距离。二维空间两
2020-09-26 14:41:34 336
原创 力扣---2020.7.11
315. 计算右侧小于当前元素的个数//暴力,超时了 hhahahaclass Solution { public List<Integer> countSmaller(int[] nums) { int len = nums.length; List<Integer> res = new ArrayList<>(); for(int i = 0;i < len ;i++){ in
2020-09-25 16:22:03 151
原创 力扣---2020.7.10
309. 最佳买卖股票时机含冷冻期class Solution { public int maxProfit(int[] prices) { int m = prices.length; int[][] dp = new int[m+2][2]; int temp = 0; for(int i = m - 1;i >= 0;i--){ // 当手里无股票时:选择1:现在买,那么第i+1天就是有股票的,所以
2020-09-23 23:27:19 227
原创 力扣---2020.7.9
面试题 17.13. 恢复空格class Solution { public int respace(String[] dictionary, String sentence) { Set<String> dict = new HashSet<>(Arrays.asList(dictionary)); int n = sentence.length(); int[] dp = new int[n + 1]; f
2020-09-22 22:38:36 160
原创 力扣---2020.7.8
面试题 16.11. 跳水板class Solution { public int[] divingBoard(int shorter, int longer, int k) { if(k<1){ return new int[]{}; } if(shorter==longer){ return new int[]{shorter*k}; } int[] res =
2020-09-21 23:16:44 149
原创 力扣---2020.7.7
112. 路径总和class Solution { public boolean hasPathSum(TreeNode root, int sum) { if(root==null) return false; sum -= root.val; if(root.left==null && root.right==null){ return sum==0; } return ha
2020-09-20 21:38:11 154
原创 力扣---2020.7.6
63. 不同路径 IIclass Solution { public int uniquePathsWithObstacles(int[][] obstacleGrid) { if(obstacleGrid.length==0 || obstacleGrid == null){ return 0; } int m = obstacleGrid.length; int n = obstacleGrid[0].l
2020-09-19 22:15:13 130
原创 力扣---2020.7.5
44. 通配符匹配class Solution { public boolean isMatch(String s, String p) { boolean[][] dp = new boolean[s.length()+1][p.length()+1]; //dp[i][j] 表示s的前i个字符和p的前j个字符是否完全匹配 dp[0][0] = true; for(int j = 1;j <= p.length();j++)
2020-09-18 20:11:37 91
原创 力扣---2020.7.4
32. 最长有效括号public class Solution { public int longestValidParentheses(String s) { int maxans = 0; int dp[] = new int[s.length()]; for (int i = 1; i < s.length(); i++) { if (s.charAt(i) == ')') { if
2020-09-17 21:34:55 150
原创 力扣---2020.7.3
108. 将有序数组转换为二叉搜索树class Solution { public TreeNode sortedArrayToBST(int[] nums) { return nums == null ? null:buildTree(nums,0,nums.length-1); } public TreeNode buildTree(int[] nums,int left,int right){ if(left>right) return
2020-09-16 21:00:25 84
原创 力扣---2020.7.2
378. 有序矩阵中第K小的元素class Solution { public int kthSmallest(int[][] matrix, int k) { int rows = matrix.length, columns = matrix[0].length; int[] sorted = new int[rows * columns]; int index = 0; for (int[] row : matrix) {
2020-09-15 21:10:07 92
原创 力扣---2020.7.1
718. 最长重复子数组class Solution { public int findLength(int[] A, int[] B) { if(A.length == 0 || B.length == 0){ return 0; } int m = A.length; int n = B.length; int[][] dp = new int[m+1][n+1]; //dp
2020-09-15 00:05:12 140
原创 力扣---2020.6.30
剑指 Offer 09. 用两个栈实现队列class CQueue { LinkedList<Integer> stack1; LinkedList<Integer> stack2; public CQueue() { stack1 = new LinkedList<>(); //come stack2 = new LinkedList<>(); // out } publ
2020-09-13 20:19:02 140
原创 力扣---2020.6.29
215. 数组中的第K个最大元素class Solution { public int findKthLargest(int[] nums, int k) { //bubbleSort(nums); //selectSort(nums); quickSort(nums,0,nums.length-1); return nums[nums.length-k]; } public void quickSort(int[]
2020-09-12 22:33:01 108
原创 力扣---2020.6.28
209. 长度最小的子数组class Solution { public int minSubArrayLen(int s, int[] nums) { int i = 0; int sum = 0; int len = 0; for (int j = 0; j < nums.length; j++) { sum += nums[j]; while (sum >= s) {
2020-09-11 18:38:13 133
原创 力扣---2020.6.27
41. 缺失的第一个正数public class Solution { public int firstMissingPositive(int[] nums) { int len = nums.length; for (int i = 0; i < len; i++) { while (nums[i] > 0 && nums[i] <= len && nums[nums[i] - 1] !=
2020-09-10 20:16:17 151
原创 力扣---2020.6.26
面试题 02.01. 移除重复节点class Solution { public ListNode removeDuplicateNodes(ListNode head) { if (head == null) { return null; } ListNode dummyHead = new ListNode(-1); dummyHead.next = head; ListNode pre =
2020-09-09 19:39:42 129
原创 ML特征工程
文章目录1. 特征工程有哪些?1.1 数据处理异常值处理缺失值处理1.2 特征归一化线性函数归一化(Min-Max Scaling)零均值归一化(Z-Score Normalization)1.3 类别型特征序号编码独热编码(one-hot)二进制编码1.4 高维组合特征的处理1.5 文本表示模型词袋模型和N-gram模型主题模型词嵌入与深度学习模型1.6 数据分桶1.7 特征构造1.8 特征选择过滤式包裹式嵌入式PCA降维技术1.9 特征工程脑图2. 机器学习优化方法2.1 常用损失函数平方损失函数log
2020-09-08 23:51:51 648
原创 力扣---2020.6.25
139. 单词拆分class Solution { public boolean wordBreak(String s, List<String> wordDict) { int n = s.length(); boolean[] memo = new boolean[n+1]; memo[0] = true; for(int i = 1;i <= n;i++){ for(int j = 0;
2020-09-08 20:38:19 88
原创 力扣---2020.6.24
16. 最接近的三数之和class Solution { public int threeSumClosest(int[] nums, int target) { Arrays.sort(nums); int ans = nums[0] + nums[1] + nums[2]; for(int i = 0;i<nums.length;i++){ int start = i+1,end = nums.length-1;
2020-09-07 21:01:41 149
原创 力扣---2020.6.23
67. 二进制求和class Solution { public String addBinary(String a, String b) { if(a == null || a.length() == 0) return b; if(b == null || b.length() == 0) return a; StringBuilder sb = new StringBuilder(); int i = a.length()-1
2020-09-06 22:17:25 182
原创 力扣---2020.6.22
面试题 16.18. 模式匹配class Solution { public boolean patternMatching(String pattern, String value) { int count_a = 0, count_b = 0; for (char ch: pattern.toCharArray()) { if (ch == 'a') { ++count_a; } e
2020-09-05 21:18:11 149
原创 力扣---2020.6.21
124. 二叉树中的最大路径和class Solution { int ans = Integer.MIN_VALUE; public int maxPathSum(TreeNode root) { getMax(root); return ans; } public int getMax(TreeNode root){ if(root==null) return 0; int left = Math.max
2020-09-04 20:19:34 135
原创 力扣---2020.6.20
10. 正则表达式匹配class Solution { public boolean isMatch(String s, String p) { int sLen = s.length(), pLen = p.length(); boolean[][] memory = new boolean[sLen+1][pLen+1]; memory[0][0] = true; for(int i = 0; i <= sLen; i++) { for(int j =
2020-09-03 20:28:10 184
原创 力扣---2020.6.19
125. 验证回文串class Solution { public boolean isPalindrome(String s) { //双指针 s = s.toLowerCase(); int left = 0; int right = s.length()-1; while(left<right){ //Character.isLetterOrDigit(char ch) 确定指定的字
2020-09-02 21:26:19 145
原创 力扣---2020.6.18
1028. 从先序遍历还原二叉树class Solution { public TreeNode recoverFromPreorder(String S) { // 存储当前节点的路径 Deque<TreeNode> path = new LinkedList<TreeNode>(); // 存储字符串中的位置 int pos = 0; while (pos < S.length())
2020-09-01 21:44:25 164
15856_eec3d8ce85-背包问题知识框架图.png
2020-05-11
新型肺炎实战.zip
2020-04-06
天池工业蒸汽.zip
2020-04-06
少年的你评论数据分析.zip
2020-04-06
金融反欺诈实战.zip
2020-04-06
国庆档电影数据分析.zip
2020-04-06
git常用命令.txt
2020-04-06
Spring-AOP.zip
2020-04-06
mantisbt-2.24.0.tar.gz
2020-04-06
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人