自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

厉兵秣码

厉兵秣“码”,砥砺前行。

  • 博客(228)
  • 资源 (1)
  • 收藏
  • 关注

原创 【怒撕剑指Offer】之「替换空格」

【怒撕剑指Offer】系列旨在用最通俗易懂的语言与动画讲解算法,培养逻辑思维,让你在互联网面试过程中不再畏惧手撕算法。1 题目描述将字符串中的空格替换成"%20"。输入:s = "We are happy."输出:"We%20are%20happy."2 解题思路有两种比较好的解决方法,第一种是直接开辟一个新的数组,然后从前向后遍历,依次将原字符串中的字符添加进数组中,如果遇到空格,则添加 %20 三个字符,这种方法的时间复杂度为 O(n)O(n)O(n),因为开辟了新的空间,额外空间复杂.

2020-11-19 00:39:34 413

原创 【怒撕剑指Offer】之「二维数组中的查找」

【怒撕剑指Offer】系列旨在用最通俗易懂的语言与动画讲解算法,培养逻辑思维,让你在互联网面试过程中不再畏惧手撕算法。1 题目描述在一个 n * m 的二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个高效的函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。[ [1, 4, 7, 11, 15], [2, 5, 8, 12, 19], [3, 6, 9, 16, 22], [10, 13, 14, 17,.

2020-11-17 23:34:13 353

原创 如何拿到互联网大厂(SP/SSP)offer?

一、背景目标岗位:后台研发工程师(Java/Go)学历背景:211硕、科班实习背景:字节实习一年项目:都是实习期间的项目Get Offer:阿里、字节、快手、美团、京东、网易、触宝。字节是实习转正,已知大SP+;触宝是学霸批;其他感觉聊的也很好,白菜以上的概率较大二、秋招经历由于学校的氛围和同学的怂恿,我的第一份实习在研一的暑假就开始了,也是第一次面试,面进了字节的日常实习,一直实习到了今年8月份,一年多的时间,这段实习经历绝对是给我背了很强的书,后面的秋招面试也十分顺畅。7月份字节转正

2020-10-14 12:18:13 36011 12

原创 剑指 Offer 最全题解——快速刷题

剑指Offer - Java题解 「上」剑指Offer - Java题解 「中」剑指Offer - Java题解 「下」

2020-01-29 23:03:47 527

原创 【栈和队列】设计一个有 getMin 功能的栈

题目实现一个特殊的栈,在实现栈的基本功能的基础上,再实现返回栈中最小元素的操作。要求pop、push、getMin 操作的时间复杂度都是 O(1)设计的栈类型可以使用现成的栈结构思路一使用两个栈,一个栈保存当前栈中的元素,一个栈保存最小值。private Stack<Integer> stackData = new Stack<Integer>();pr...

2019-12-15 08:59:16 205

原创 Windows 10 安装 CUDA 失败之屡败屡战

想要在 Windows 10 + 1060 上搭一下 TensorFlow 的环境,可是安装 CUDA 一直,尝试了 N 种方法,最后使用 DDU 工具在安全模式下卸载了 NVIDIA 相关的内容,重新安装后就成功了,如果其他方式不行可以尝试一下这个。...

2019-11-28 18:05:23 4315 1

转载 JSON Web Token 入门教程

转载自:JSON Web Token 入门教程 - 阮一峰JSON Web Token(缩写 JWT)是目前最流行的跨域认证解决方案,本文介绍它的原理和用法。一、跨域认证的问题互联网服务离不开用户认证。一般流程是下面这样。1、用户向服务器发送用户名和密码。2、服务器验证通过后,在当前对话(session)里面保存相关数据,比如用户角色、登录时间等等。3、服务器向用户返回一个 sess...

2019-06-23 17:22:30 151

原创 【Leetcode】42. 接雨水(Trapping Rain Water)

Leetcode - 42 Trapping Rain Water (Hard)题目描述:给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。 Input: [0,1,0,2,1,0,1,3,2,1,2,1]Output: 6解题思路:双指针public int trap(int[] height) { int left = ...

2019-06-09 09:19:56 224

原创 【Leetcode】41. 缺失的第一个正整数(First Missing Positive)

Leetcode - 41 First Missing Positive (Hard)Input: [3,4,-1,1]Output: 2public int firstMissingPositive(int[] nums) { int i = 0; while (i < nums.length) { if (nums[i] >= 1 &amp...

2019-06-08 23:06:54 270

原创 【Leetcode】48. 旋转图像(Rotate Image)

Leetcode - 48 Rotate Image (Medium)题目描述:将一个 n × n 的矩阵旋转 90°,不能使用额外的辅助空间。Given input matrix = [ [1,2,3], [4,5,6], [7,8,9]],rotate the input matrix in-place such that it becomes:[ [7,4,1]...

2019-06-08 22:44:32 187

原创 【Leetcode】46. 全排列(Permutations)

Leetcode - 46 Permutations (Medium)题目描述: 给定无重复的整数序列,返回所有全排列的可能。Input: [1,2,3]Output:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]public List<List<Integer>> per...

2019-06-08 22:36:26 145

原创 【Leetcode】36. 有效的数独(Valid Sudoku)

Leetcode - 36 Valid Sudoku (Medium)题目描述:给定一个 9 × 9 的不完整数独数组,判定是否合法。解题思路:判断每一行、每一列和每个 3 × 3 单元格是否有重复的数字。public boolean isValidSudoku(char[][] board) { boolean[][] row = new boolean[9][9]; bo...

2019-06-06 10:19:40 154

原创 【Leetcode】34. 在排序数组中查找元素的第一个和最后一个位置(Find First and Last Position of Element in Sorted Array)

Leetcode - 34 Find First and Last Position of Element in Sorted Array (Medium)题目描述:给定一个有序序列与一个 target 值,求出 target 在有序序列中的区间,时间复杂度要求为 O(logn),若没有 target 值,则返回 [-1, -1]。Input: nums = [5,7,7,8,8,10], t...

2019-06-06 09:56:32 153

原创 【Leetcode】33. 搜索旋转排序数组(Search in Rotated Sorted Array)

Leetcode - 33 Search in Rotated Sorted Array (Medium)题目描述:给定一个旋转的有序数组,例如有序数组 [0,1,2,4,5,6,7] 经一次旋转后可得 [4,5,6,7,0,1,2] ,再给定一个 target 值,返回 target 值在数组中的下标,如果不在返回 -1,假设数组中无重复元素,时间复杂度要求为 O(logn)。Input:...

2019-06-06 09:40:03 179

原创 Mybatis BindingException 找不到 mapper.xml

运行 SSM 项目的时候抛出如下异常:org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)...

2019-06-05 11:47:19 475

原创 【Leetcode】29. 两数相除(Divide Two Integers)

Leetcode - 29 Divide Two Integers (Medium)题目描述:不使用乘法、除法和 mod 运算符。Input: dividend = 10, divisor = 3Output: 3解题思路:注意整数溢出的情况, 可以利用二分的思想优化求解。public int divide(int dividend, int divisor) { int si...

2019-06-05 09:09:46 178

原创 【Leetcode】28. 实现 strStr()(Implement strStr())

Leetcode - 28. Implement strStr() (Easy)题目描述:返回匹配字符串首字母的下标,不存在返回 -1。Input: haystack = "hello", needle = "ll"Output: 2解题思路:注意 needle 长度为 0 时返回 0,而不是 -1。public int strStr(String haystack, String n...

2019-06-05 08:48:20 127

原创 【Leetcode】26. 删除有序数组中的重复项(Remove Duplicates from Sorted Array)

Leetcode - 26 Remove Duplicates from Sorted Array (Easy)Given nums = [0,0,1,1,1,2,2,3,3,4],Your function should return length = 5, with the first five elements of nums being modified to 0, 1, 2, 3,...

2019-06-05 08:32:15 425

原创 【Leetcode】23. 合并 k 个有序链表(Merge k Sorted Lists)

Leetcode - 23 Merge k Sorted Lists (Hard)Input:[ 1->4->5, 1->3->4, 2->6]Output: 1->1->2->3->4->4->5->6解题思路:这道题类似之前的合并两个有序链表,可以逐个两两合并,也可以每次取出链表头部的最小节点,我也...

2019-06-04 22:52:53 166

原创 【Leetcode】22. 生成括号(Generate Parentheses)

Leetcode - 22 Generate Parentheses (Medium)题目描述:给定整数 n,生成包含 n 个括号合法字符串的所有组合。[ "((()))", "(()())", "(())()", "()(())", "()()()"]解题思路:结合合法括号的特性。public List<String> generateParenthe...

2019-06-04 22:34:28 126

原创 【Leetcode】21. 合并两个有序链表(Merge Two Sorted Lists)

Leetcode - 21 Merge Two Sorted Lists (Easy)Input: 1->2->4, 1->3->4Output: 1->1->2->3->4->4解法一:迭代public ListNode mergeTwoLists(ListNode l1, ListNode l2) { ListNode d...

2019-06-04 22:25:19 122

原创 【Leetcode】20.有效的括号(Valid Parenthese)

Leetcode - 20 Valid Parenthese (Easy)题目描述:给定字符串,判断括号是否有效。Input: "()[]{}"Output: truepublic boolean isValid(String s) { Stack<Character> stack = new Stack<>(); for (Character c...

2019-06-04 22:16:07 123

原创 【Leetcode】19. 删除链表的倒数第 n 个节点(Remove Nth Node From End of List)

Leetcode - 19 Remove Nth Node From End of List (Medium)Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the linked list becomes 1->2->3-&gt...

2019-06-04 09:02:57 127

原创 【Leetcode】17. 电话号码的字母组合(Letter Combinations of a Phone Number)

Leetcode - 17 Letter Combinations of a Phone Number (Medium) Input: "23"Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].Map<String, String> map = new HashMap<String, Str...

2019-06-04 08:51:24 149

原创 【Leetcode】15. 三数之和(3Sum)

Leetcode - 15 3Sum (Medium)题目描述:找出数组中三数和为 0 的组合。Given array nums = [-1, 0, 1, 2, -1, -4],A solution set is:[ [-1, 0, 1], [-1, -1, 2]]解题思路:注意去重。public List<List<Integer>> three...

2019-06-04 08:21:35 130

原创 【Leetcode】14. 最长公共前缀(Longest Common Prefix)

Leetcode - 14 Longest Common Prefix (Easy)Input: ["flower","flow","flight"]Output: "fl"public String longestCommonPrefix(String[] strs) { if (strs.length == 0) return ""; String prefix = s...

2019-06-03 22:49:18 103

原创 【Leetcode】13. 罗马数字转整数(Roman to Integer)

Leetcode - 13 Roman to Integer (Easy)题目描述:Symbol ValueI 1V 5X 10L 50C 100D 500M 1000I can be place...

2019-06-03 10:22:33 130

原创 【Leetcode】11. 盛最多水的容器(Container With Most Water)

Leetcode - 11 Container With Most Water (Medium)题目描述:找出两条线,使得构成的容器能够容纳最多的水。 public int maxArea(int[] height) { int max = 0, i = 0, j = height.length - 1; while (i < j) { max = ...

2019-06-03 10:07:08 119

原创 【Leetcode】10. 正则表达式匹配(Regular Expression Matching)

Leetcode - 10 Regular Expression Matching (Hard)题目描述:. 表示任意字符,* 表示它前面的字符可以出现任意次(包含 0 次)。Input:s = "aab"p = "c*a*b"Output: trueExplanation: c can be repeated 0 times, a can be repeated 1 time. Th...

2019-06-03 09:56:43 126

原创 【Leetcode】7. 整数反转(Reverse Integer)

Leetcode - 7 Reverse Integer (Easy)题目描述:反转一个 32 位有符号的整数。Input: -123Output: -321解题思路:注意整型范围越界。public int reverse(int x) { int result = 0; while (x != 0) { int tail = x % 10; ...

2019-06-02 20:35:49 148

原创 【Leetcode】5. 最长回文子串(Longest Palindromic Substring)

Leetcode - 5 Longest Palindromic Substring (Medium)Input: "babad"Output: "bab"Note: "aba" is also a valid answer.private int lo, maxLen;public String longestPalindrome(String s) { int len = ...

2019-06-02 14:17:04 115

原创 【Leetcode】4. 寻找两个有序数组的中位数(Median of Two Sorted Arrays)

Leetcode - 4 Median of Two Sorted Arrays (Hard)题目描述:要求时间复杂度为 O(log(m + n))。nums1 = [1, 3]nums2 = [2]The median is 2.0解题思路:二分。 left_part | right_partA[0], A[1], ..., A[i-1...

2019-06-02 13:59:56 179

原创 【Leetcode】3. 无重复字符的最长子串(Longest Substring Without Repeating Characters)

Leetcode - 3 Longest Substring Without Repeating Characters (Medium)Input: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3. 解题思路:使用 HashMap 记录出现字符的位置,利用双指针滑动窗口记录子串的长度。...

2019-06-02 11:28:31 128

原创 【Leetcode】2. 两数相加(Add Two Numbers)

Leetcode - 2 Add Two Numbers (Medium)题目描述:使用链表表示两个正整数,返回两正整数相加结果,使用链表表示。Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)Output: 7 -> 0 -> 8Explanation: 342 + 465 = 807.public ListNode addT...

2019-06-02 11:06:21 202

原创 【Leetcode】1. 两数之和(Two Sum)

Leetcode - 1 Two Sum (Easy)题目描述:给定一个数组,返回相加和为 target 的两个元素的下标。Given nums = [2, 7, 11, 15], target = 9,Because nums[0] + nums[1] = 2 + 7 = 9,return [0, 1].public int[] twoSum(int[] nums, int tar...

2019-06-02 10:52:19 147

原创 【Leetcode】27. 移除元素(Remove Element)

Leetcode - 27 Remove Element (Easy)题目描述:在不使用额外空间的情况下,删除数组中的 val,返回删除后的数组长度。Given nums = [3,2,2,3], val = 3,Your function should return length = 2, with the first two elements of nums being 2.It ...

2019-06-01 10:54:33 138

原创 【Leetcode】1010. 总持续时间可被 60 整除的歌曲(Pairs of Songs With Total Durations Divisible by 60)

Leetcode - 1010 Pairs of Songs With Total Durations Divisible by 60 (Easy)题目描述:数组中每个元素表示歌曲的播放时间,找出所有两首歌曲时间相加之和是 60 分钟倍数的数量。Input: [30,20,150,100,40]Output: 3Explanation: Three pairs have a total d...

2019-06-01 10:40:27 162

原创 【Leetcode】628. 三个数的最大乘积(Maximum Product of Three Numbers)

Leetcode - 628 Maximum Product of Three Numbers (Easy)题目描述:给定一个数组,找出三个数的最大乘积。Input: [1,2,3,4]Output: 24解题思路:三个数的最大乘积有两种情况,第一种是三个最大正数相乘,第二种是两个最小的负数与一个最大正数相乘,这就转变为如何找到这 5 个数。public int maximumProd...

2019-06-01 10:14:31 129

原创 【Leetcode】118. 杨辉三角(Pascal's Triangle)

Leetcode - 118 Pascal’s Triangle (Easy)Input: 5Output:[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]public List<List<Integer>> generate(int numRows) { List<List...

2019-06-01 10:01:43 116

原创 【Leetcode】1018. 可被 5 整除的二进制前缀(Binary Prefix Divisible By 5)

Leetcode - 1018 Binary Prefix Divisible By 5 (Easy)题目描述:给定一个由 0 和 1 组成的数组,定义 Ni 为 从 A[0] 到 A[i] 的第 i 个子数组被解释为一个二进制数(从最高有效位到最低有效位)。返回布尔值列表 answer,判断 Ni 是否能够被 5 整除。Input: [0,1,1,1,1,1]Output: [true,f...

2019-05-31 22:34:41 152

Java使用json所用的jar包

包含java解析或存入json格式文件的6个jar包,包括:json-lib-2.4-jdk15.jar、commons-beanutils-1.9.3.jar、commons-collections4-4.2.jar、commons-lang-2.5.jar、commons-logging-1.2.jar与ezmorph-1.0.6.jar

2018-07-16

空空如也

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

TA关注的人

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