首页
题库
公司真题
专项练习
面试题库
在线编程
面试
面试经验
AI 模拟面试
简历
求职
学习
课程
专栏·文章
竞赛
搜索
我要招人
发布职位
发布职位、邀约牛人
更多企业解决方案
在线笔面试、雇主品牌宣传
登录
/
注册
牛客709025891号
获赞
89
粉丝
0
关注
5
看过 TA
2
男
重庆邮电大学
2022
安卓
IP属地:未知
暂未填写个人简介
私信
关注
拉黑
举报
举报
确定要拉黑牛客709025891号吗?
发布(11)
刷题
牛客709025891号
2022-02-26 19:37
已编辑
安卓
java读取 classpath 资源
根据廖雪峰老师的这个步骤 https://www.liaoxuefeng.com/wiki/1252599548343744/1298366384308257#0 在进行到下面这一步的时候,input为null try (InputStream input = getClass().getResourceAsStream("/default.properties")) { if (input != null) { // TODO: } } 于是在本机IDEA上测试,如下代码: System.out.println(JZ3.class.getResource...
0
点赞
评论
收藏
转发
牛客709025891号
2022-02-24 12:52
安卓
题解 | #从尾到头打印链表#
法一 新建数组,倒序存储 一遍历得长度,据此新建等长数组,二遍历倒序存储 时间复杂度:O(N),但是是两次 空间复杂度:O(N) public ArrayList<Integer> printListFromTailToHead(ListNode listNode) { //创建一等长数组,逆序存储 ListNode p = listNode; int n = 0; while(p != null){ n++; p = p.next; } ...
0
点赞
评论
收藏
转发
牛客709025891号
2022-02-23 09:08
安卓
题解 | #替换空格#
法一 使用自带replace方法 public String replaceSpace (String s) { // write code here return s.replace(" ","%20"); } 可见时间复杂度很高 法二 使用StringBuilder import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param s string字符串...
0
点赞
评论
收藏
转发
牛客709025891号
2022-02-22 22:03
安卓
题解 | #二维数组中的查找#
从右上角(本解法)或者左下角夹逼即可 public class Solution { public boolean Find(int target, int [][] array) { if(array == null || array.length == 0) return false; int row = array.length, col = array[0].length; int i = 0, j = col-1; while(i < row && j >= 0){ ...
0
点赞
评论
收藏
转发
牛客709025891号
2022-02-22 21:55
安卓
题解 | #数组中重复的数字#
法一,使用Set 一次遍历,遍历的时候添加元素,如果add返回为false,则此元素重复; public int duplicate (int[] numbers) { // write code here Set<Integer> set = new HashSet<>(); for(int i=0;i<numbers.length;i++){ if(!set.add(numbers[i])){ return numbers[i]; ...
0
点赞
评论
收藏
转发
牛客709025891号
2021-04-15 11:23
安卓
题解 | #包含min函数的栈#
题解如代码,需要使用一个辅助栈,用来存当前最小值: import java.util.Stack; public class Solution { Stack<Integer> stack = new Stack<>(); //需要一个辅助栈来存放最小元素,该辅助栈栈顶则为当前最小元素 Stack<Integer> minStack = new Stack<>(); int min = Integer.MAX_VALUE; public void push(int node) { ...
0
点赞
评论
收藏
转发
牛客709025891号
2021-04-15 11:09
安卓
题解 | #顺时针打印矩阵#
题解如代码: public ArrayList<Integer> printMatrix(int [][] matrix) { int[] dx = {0,1,0,-1}; int[] dy = {1,0,-1,0}; int i =0,j=0; int rows = matrix.length; int cols = matrix[0].length; boolean[][] visited = new boolean[rows][cols]; int max ...
0
点赞
评论
收藏
转发
牛客709025891号
2021-04-15 10:26
安卓
题解 | #树的子结构#
题解如代码: public class Solution { public boolean HasSubtree(TreeNode root1,TreeNode root2) { //如果其中一个为null,返回false if(root1 == null || root2 == null) return false; //由于子串root2的根节点可能存在于root1的任何一个节点,所以这里使用 || 连接 return recur(root1,root2) || HasSubtree(root1.left,root2)...
0
点赞
评论
收藏
转发
牛客709025891号
2021-04-14 19:26
安卓
难顶
2021-04-14
在牛客打卡1天,今天学习:刷题 12 道/代码提交 48 次/学习课程 1 节
每日监督打卡
0
点赞
评论
收藏
转发
牛客709025891号
2021-04-14 15:44
安卓
题解 | #链表中倒数第k个结点#
首先一次遍历计算出链表长度;然后从头开始遍历,遍历到k-i就返回(i为链表下标,从0开始) public ListNode FindKthToTail (ListNode pHead, int k) { // write code here //先计算出长度,然后循环判断 ListNode dummy = new ListNode(0); dummy.next = pHead; ListNode temp = pHead; int len = 0; while(temp != nul...
0
点赞
评论
收藏
转发
牛客709025891号
2021-04-14 15:21
安卓
题解 | #调整数组顺序使奇数位于偶数前面#
头尾双指针,一次遍历,头处理奇数,尾处理偶数;时间复杂度:O(N)空间复杂度:O(N) public int[] reOrderArray (int[] array) { // write code here //双指针,头尾指针 int[] nums = new int[array.length]; int head = 0; int tail = array.length-1; int index_head = head; int index_tail = tail; ...
0
点赞
评论
收藏
转发
1
工具箱
TA的圈子
暂未加入圈子
TA的圈子
TA的笔记
暂无笔记
TA的笔记
登录
0
天
已登录
0
天
连续登录
0
人
今日访客
牛客网
牛客企业服务