Skip to content

Commit 85ccc02

Browse files
左程云左程云
左程云
authored and
左程云
committed
modify code on class
1 parent 163e0fd commit 85ccc02

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/topinterviewquestions/Problem_0048_RotateImage.java

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
public class Problem_0048_RotateImage {
44

55
public static void rotate(int[][] matrix) {
6+
// matrix.len == matrix[0].len
67
int tR = 0;
78
int tC = 0;
89
int dR = matrix.length - 1;

src/topinterviewquestions/Problem_0050_PowXN.java

+34-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public class Problem_0050_PowXN {
44

5-
public static double myPow(double x, int n) {
5+
public static double myPow1(double x, int n) {
66
if (n == 0) {
77
return 1D;
88
}
@@ -22,4 +22,37 @@ public static double myPow(double x, int n) {
2222
return n < 0 ? (1D / ans) : ans;
2323
}
2424

25+
public static double myPow2(double x, int n) {
26+
if (n == 0) {
27+
return 1D;
28+
}
29+
int pow = Math.abs(n == Integer.MIN_VALUE ? n + 1 : n);
30+
double t = x;
31+
double ans = 1D;
32+
while (pow != 0) {
33+
if ((pow & 1) != 0) {
34+
ans *= t;
35+
}
36+
pow >>= 1;
37+
t = t * t;
38+
}
39+
if (n == Integer.MIN_VALUE) {
40+
ans *= x;
41+
}
42+
return n < 0 ? (1D / ans) : ans;
43+
}
44+
45+
public static void main(String[] args) {
46+
System.out.println("world shut up!");
47+
int a = Integer.MIN_VALUE;
48+
int b = -a;
49+
System.out.println(b);
50+
double test = 1.0000001D;
51+
System.out.println(test == 1D);
52+
System.out.println(Math.pow(test, (double) Integer.MIN_VALUE));
53+
System.out.println(myPow1(test, Integer.MIN_VALUE));
54+
System.out.println(myPow2(test, Integer.MIN_VALUE));
55+
56+
}
57+
2558
}

0 commit comments

Comments
 (0)