没有合适的资源?快使用搜索试试~ 我知道了~
剑指offer-java-pdf1
资源详情
资源评论
资源推荐
public BinaryTreeNode(int data) {
super();
this.data = data;
}
public int getData() {
return data;
}
public void setData(int data) {
this.data = data;
}
public BinaryTreeNode getLchildNode() {
return LchildNode;
}
public void setLchildNode(BinaryTreeNode lchildNode) {
LchildNode = lchildNode;
}
public BinaryTreeNode getRchildNode() {
return RchildNode;
}
public void setRchildNode(BinaryTreeNode rchildNode) {
RchildNode = rchildNode;
}
}
@-6:
class Node {
String data;
Node next;
public Node(String data) {
super();
this.data = data;
}
public Node(String data, Node next) {
super();
this.data = data;
this.next = next;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public Node getNext() {
return next;
}
public void setNext(Node next) {
this.next = next;
}
}
题解
A+B 设计个类,我们只能成该类的个实。
// 饿汉式 线程安全
class A {
private static final A instance = new A();
private A() {
}
public static A getInstance() {
return instance;
}
}
// 懒汉式 线程安全写法
class B {
private static volatile B instance = null;
private B() {
}
public static B getInstance() {
if (instance == null) {
synchronized (B.class) {
if (instance == null)
instance = new B();
}
}
return instance;
}
}
// 静态内部类式 线程安全
class C {
private C() {
}
public static C getInstance() {
return CHolder.INSTANCE;
}
private static class CHolder {
private static final C INSTANCE = new C();
}
}
C+B 在个维数组中,每都按照从左到右递增的顺序排序,每都按
照从上到下递增的顺序排序。请完成个函数,输这样的个维数组
和个整数,判断数组中是否函数该整数。
public class No03 {
public static void main(String[] args) {
int[][] arr = {{1, 2, 8, 9},
{2, 4, 9, 12},
{4, 7, 10, 13},
{6, 8, 11, 15}};
System.out.println(search(arr, 7));
}
private static boolean search(int[][] arr, int value) {
int a = arr[0].length;
int b = arr.length;
int i = 0;
int j = a - 1;
while (i <= b - 1 && j >= 0) {
if (arr[i][j] == value) {
return true;
}
if (arr[i][j] > value) {
j--;
} else {
i++;
}
}
return false;
}
}
D+B 请实现个函数,把字符中的每个空格替换成EF;GE。如输EH:B=0:
!=##>E,则输出EH:F;G=0:F;G!=##>E
public class No04 {
public static void main(String[] args) {
String str = "We are happy";
剩余51页未读,继续阅读
艾苛尔
- 粉丝: 26
- 资源: 307
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0