Skip to content

Commit 0cd666d

Browse files
authored
Merge pull request #1301 from fishercoder1534/master
[pull] master from fishercoder1534:master
2 parents 267371d + df7a9cb commit 0cd666d

File tree

4,015 files changed

+72723
-53666
lines changed

Some content is hidden

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

4,015 files changed

+72723
-53666
lines changed

.github/workflows/gradle.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1818
with:
1919
fetch-depth: 0
20-
- name: Set up JDK 11
21-
uses: actions/setup-java@v3
20+
- name: Set up JDK 17
21+
uses: actions/setup-java@v4
2222
with:
2323
distribution: 'temurin'
24-
java-version: '11'
24+
java-version: '17'
2525
cache: 'gradle'
2626
- name: Build with Gradle
2727
run: chmod +x gradlew && ./gradlew build

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ out/
66
*.iml
77
*.vscode/
88
src/main/java/com/fishercoder/solutions/_99999RandomQuestions.java
9-
.project
9+
src/main/java/com/fishercoder/solutions/_Contest.java
10+
.project
11+
bin

README.md

Lines changed: 12 additions & 1524 deletions
Large diffs are not rendered by default.

build.gradle

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,72 @@
1-
apply plugin: 'java'
2-
apply plugin: 'checkstyle'
1+
plugins {
2+
id 'java'
3+
id 'checkstyle'
4+
id 'com.diffplug.spotless' version '6.25.0'
5+
}
36

47
group = 'com.fishercoder'
58
version = '1.0-SNAPSHOT'
69

7-
javadoc.options.encoding = 'UTF-8'
8-
compileJava.options.encoding = 'UTF-8'
9-
10-
checkstyle {
11-
//include ( '**/*.java')
12-
configFile = file("${rootDir}/fishercoder_checkstyle.xml")
13-
}
14-
15-
sourceSets {
16-
main {
17-
java {
18-
srcDir 'src/fishercoder'
19-
}
10+
java {
11+
toolchain {
12+
languageVersion = JavaLanguageVersion.of(17)
2013
}
2114
}
2215

23-
description = """"""
16+
tasks.javadoc {
17+
options.encoding = 'UTF-8'
18+
}
2419

25-
sourceCompatibility = 1.8
26-
targetCompatibility = 1.8
20+
tasks.compileJava {
21+
options.encoding = 'UTF-8'
22+
}
2723

2824
repositories {
2925
mavenCentral()
30-
maven { url "http://repo.maven.apache.org/maven2" }
3126
}
3227

3328
dependencies {
34-
compile 'com.google.code.gson:gson:2.8.0'
35-
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.0'
29+
implementation 'com.google.code.gson:gson:2.10.1'
30+
implementation 'org.apache.commons:commons-collections4:4.0'
31+
32+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'
33+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3'
3634

37-
// TODO: to remove Junit4 after all tests are migrated to Junit5
38-
compile 'junit:junit:4.13'
39-
testCompile "junit:junit:4.13.1"
35+
testImplementation 'org.assertj:assertj-core:3.11.1'
36+
compileOnly 'org.projectlombok:lombok:1.18.32'
37+
annotationProcessor 'org.projectlombok:lombok:1.18.32'
38+
testCompileOnly 'org.projectlombok:lombok:1.18.32'
39+
testAnnotationProcessor 'org.projectlombok:lombok:1.18.32'
40+
}
4041

41-
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
42-
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
42+
testing {
43+
suites {
44+
test {
45+
useJUnitJupiter()
46+
}
47+
}
48+
}
4349

44-
testCompile("org.assertj:assertj-core:3.11.1")
45-
compileOnly 'org.projectlombok:lombok:1.18.12'
46-
annotationProcessor 'org.projectlombok:lombok:1.18.12'
47-
testCompileOnly 'org.projectlombok:lombok:1.18.12'
48-
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
50+
tasks.withType(Test).configureEach {
51+
maxParallelForks = Runtime.runtime.availableProcessors()
4952
}
5053

51-
test {
52-
useJUnitPlatform()
54+
checkstyle {
55+
toolVersion = '6.17'
56+
config = rootProject.resources.text.fromFile('fishercoder_checkstyle.xml')
57+
}
58+
59+
spotless {
60+
java {
61+
encoding 'UTF-8'
62+
target fileTree(projectDir) {
63+
include '**/src/**/*.java'
64+
exclude '**/build/**'
65+
}
66+
importOrder '\\#', '', '*'
67+
removeUnusedImports()
68+
googleJavaFormat('1.22.0').aosp()
69+
toggleOffOn()
70+
endWithNewline()
71+
}
5372
}

cpp/_916.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
class Solution {
2+
public:
3+
vector<string> wordSubsets(vector<string>& words1, vector<string>& words2) {
4+
int maxCharFreq[26] = {0};
5+
int tempCharFreq[26];
6+
for (const auto& word : words2) {
7+
memset(tempCharFreq, 0, sizeof tempCharFreq);
8+
for (char ch : word) {
9+
tempCharFreq[ch - 'a']++;
10+
}
11+
for (int i = 0; i < 26; ++i) {
12+
maxCharFreq[i] = max(maxCharFreq[i], tempCharFreq[i]);
13+
}
14+
}
15+
vector<string> universalWords;
16+
for (const auto& word : words1) {
17+
memset(tempCharFreq, 0, sizeof tempCharFreq);
18+
for (char ch : word) {
19+
tempCharFreq[ch - 'a']++;
20+
}
21+
bool isUniversal = true;
22+
for (int i = 0; i < 26; ++i) {
23+
if (maxCharFreq[i] > tempCharFreq[i]) {
24+
isUniversal = false;
25+
break;
26+
}
27+
}
28+
if (isUniversal) {
29+
universalWords.emplace_back(word);
30+
}
31+
}
32+
return universalWords;
33+
}
34+
};

database/_1741.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- # Write your MySQL query statement below
2+
select event_day as day, emp_id, sum(out_time - in_time) as total_time
3+
from Employees
4+
group by day, emp_id

database/_1789.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- # Write your MySQL query statement below
2+
select employee_id, department_id
3+
from (select *, count(employee_id) over(partition by employee_id) as EmployeeCount from Employee) EP
4+
where EmployeeCount = 1
5+
or primary_flag = 'Y';

database/_1795.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Write your PostgreSQL query statement below
2+
select product_id, 'store1' as store, store1 as price
3+
from Products
4+
where store1 is not null
5+
union
6+
select product_id, 'store2' as store, store2 as price
7+
from Products
8+
where store2 is not null
9+
union
10+
select product_id, 'store3' as store, store3 as price
11+
from Products
12+
where store3 is not null

database/_1809.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- Write your PostgreSQL query statement below
2+
-- my completely original solution
3+
with sessions_with_ads as (select p.customer_id, p.session_id, p.start_time, p.end_time, a.timestamp as ts, a.ad_id
4+
from Playback p
5+
inner join Ads a
6+
on p.customer_id = a.customer_id and
7+
a.timestamp between p.start_time and p.end_time)
8+
9+
select distinct(session_id)
10+
from (select distinct(session_id) from Playback)
11+
where session_id not in (select distinct(session_id) from sessions_with_ads)
12+
13+

database/_1821.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Write your PostgreSQL query statement below
2+
select customer_id from Customers where revenue > 0 and year = 2021;

0 commit comments

Comments
 (0)