Skip to content

Commit a259ea4

Browse files
committed
Update: 2020/03/02
1 parent 533d1c9 commit a259ea4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+158
-40
lines changed

CCF/CCSP/2019/sql/std.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/python3
22
#-*- coding=utf-8 -*-
3-
import sys
43
import sqlite3
54

65
db = sqlite3.connect(':memory:')

CCF/CSP/2017/17122.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from queue import Queue
21
n, k = map(int, input().split())
32
q = []
43
for i in range(1, n + 1):

CodingInterviews/Fibonacci.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
public class Fibonacci {
2+
public static void main(String[] args) {
3+
int n = 100;
4+
System.out.println(fib(n));
5+
}
6+
7+
private static int fib(int n) {
8+
if (n <= 1)
9+
return n;
10+
long a = 0, b = 1;
11+
long ans = 0;
12+
for (int i = 2; i <= n; i++) {
13+
ans = (a + b) % 1000000007;
14+
a = b;
15+
b = ans;
16+
}
17+
return (int) ans;
18+
}
19+
}

CodingInterviews/RepeatNumber.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.util.HashSet;
2+
import java.util.Set;
3+
4+
public class RepeatNumber {
5+
public static void main(String[] args) {
6+
int[] nums = { 2, 3, 1, 0, 2, 5, 3 };
7+
System.out.println(findRepeatNumber(nums));
8+
}
9+
10+
private static int findRepeatNumber(int[] nums) {
11+
int repeat = -1;
12+
Set<Integer> set = new HashSet<Integer>();
13+
for (int num : nums) {
14+
if (!set.add(num)) {
15+
repeat = num;
16+
break;
17+
}
18+
}
19+
return repeat;
20+
}
21+
}

CodingInterviews/ReplaceSpace.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class ReplaceSpace {
2+
public static void main(String[] args) {
3+
String s = "We are happy.";
4+
System.out.println(replaceSpace(s));
5+
}
6+
7+
private static String replaceSpace(String s) {
8+
StringBuilder ans = new StringBuilder();
9+
for (char c : s.toCharArray()) {
10+
if (c == ' ')
11+
ans.append("%20");
12+
else
13+
ans.append(c);
14+
}
15+
return ans.toString();
16+
}
17+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

HDU/p3.c renamed to HDOJ/p3.c

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)