暗影沉香
暗影沉香
全部文章
分类
Android(1)
C/C++算(2)
Java(1)
LeeetCode(3)
USTC中科大机试(58)
分布式与云计算(1)
数据结构及相关算法(8)
未归档(1)
机器学习(1)
计算机视觉(2)
题解(18)
归档
标签
去牛客网
登录
/
注册
暗影沉香
高山仰止 景行行止
全部文章
(共96篇)
删除链表中重复的结点
思想: **** 1.pHead为null或者pHead.next==null,返回pHead。* 2.否则,初始化pre和itr,pre指向pHead,pHead指向itr,以方便可以同时删除多个重复的节点(中间始终隔了一个节点),初始化flag标记itr前一个节点是否是...
2020-03-10
0
577
链表中环的入口结点
双指针法:时间o(N),空间O(1) P1 每次走一个节点,p2每次走两个节点,则相遇时 p2比p1多走了一环(画图可知)设为s,不妨设p1走了x,则p2走了2x(速度两倍), 2x-x=s=>p1实际走了一环路程,p2重新指向头结点,p1不变(...
2020-03-08
0
517
字符流中第一个不重复的字符
队列:空间O(1),时间O(1) import java.util.*; public class Solution { //Map<Character,Integer> map = new LinkedHashMap<>(); //Insert one ch...
2020-03-08
0
476
表示数字的字符串
public class Solution { public boolean isNumeric(char[] str) { if(str==null)return false; return match(str,false,false,0); } ...
2020-03-08
0
551
正则表达式匹配
public class Solution { public boolean match(char[] str, char[] pattern) { if(str==null||pattern==null)return false; int s=0,p...
2020-03-08
1
593
构建乘积数组
链接:https://www.nowcoder.com/questionTerminal/94a4d381a68b47b7a8bed86f2975db46?answerType=1&f=discussion 来源:牛客网 给定一个数组A[0,1,...,n-1],请构建一个数组B[0,1,...
2020-03-07
1
500
数组中重复的数字
import java.util.*; public class Solution { // Parameters: // numbers: an array of integers // length: the length of array ...
2020-03-07
0
473
把字符串转换成整数
为防止溢出,把符号位和值位设为long,在求值的过程中如果long型超过了Integer.MAX,或者小于Integer.MIN返回0即可,否则强制类型转换int型返回。 public class Solution { public int StrToInt(String str) { ...
2020-03-06
1
666
不用加减乘除做加法
进位值与非进位值一直异或,直至进位值为0结束。 public class Solution { public int Add(int num1,int num2) { while(num2!=0){//当进位为0时加法完成 int temp = n...
2020-03-06
0
603
求1+2+3+...+n
public class Solution { public int Sum_Solution(int n) { //方法一短路与 /* int ans = n; boolean flag = (ans>0) &&...
2020-03-06
1
503
首页
上一页
1
2
3
4
5
6
7
8
9
10
下一页
末页