Skip to content

Commit 86b579f

Browse files
committed
Initial commit with new maven pom
0 parents  commit 86b579f

File tree

253 files changed

+18955
-0
lines changed

Some content is hidden

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

253 files changed

+18955
-0
lines changed

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Do not version control these files
2+
*.class
3+
*.log
4+
*.ctxt
5+
.mtj.tmp/
6+
*.jar
7+
*.war
8+
*.nar
9+
*.ear
10+
*.zip
11+
*.tar.gz
12+
*.rar
13+
hs_err_pid*
14+
.DS_Store
15+
.AppleDouble
16+
.LSOverride
17+
Icon
18+
._*
19+
.DocumentRevisions-V100
20+
.fseventsd
21+
.Spotlight-V100
22+
.TemporaryItems
23+
.Trashes
24+
.VolumeIcon.icns
25+
.com.apple.timemachine.donotpresent
26+
.AppleDB
27+
.AppleDesktop
28+
Network Trash Folder
29+
Temporary Items
30+
.apdisk
31+
.idea/
32+
cmake-build-debug/
33+
cmake-build-release/
34+
*.iws
35+
*.iml
36+
out/
37+
.idea_modules/
38+
atlassian-ide-plugin.xml
39+
com_crashlytics_export_strings.xml
40+
crashlytics.properties
41+
crashlytics-build.properties
42+
fabric.properties

pom.xml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.rampatra.adsj</groupId>
8+
<artifactId>adsj</artifactId>
9+
<version>1.0.0-SNAPSHOT</version>
10+
<packaging>pom</packaging>
11+
12+
<name>Algorithms and Data Structures in Java</name>
13+
<description>My solutions to some of the algorithm and data structure questions in Java</description>
14+
<url>https://github.com/rampatra/Algorithms-and-Data-Structures-in-Java</url>
15+
16+
<developers>
17+
<developer>
18+
<id>ram</id>
19+
<name>Ram Patra</name>
20+
<email>hi at rampatra.com</email>
21+
<organization>RamPatra.com</organization>
22+
<organizationUrl>http://www.rampatra.com</organizationUrl>
23+
</developer>
24+
</developers>
25+
26+
<licenses>
27+
<license>
28+
<name>GPL-3.0</name>
29+
<url>https://opensource.org/licenses/GPL-3.0</url>
30+
</license>
31+
</licenses>
32+
33+
<scm>
34+
<url>https://github.com/rampatra/Algorithms-and-Data-Structures-in-Java</url>
35+
<connection>scm:git:git://github.com/rampatra/Algorithms-and-Data-Structures-in-Java.git</connection>
36+
<developerConnection>scm:git:ssh://[email protected]/rampatra/Algorithms-and-Data-Structures-in-Java.git</developerConnection>
37+
<tag>HEAD</tag>
38+
</scm>
39+
40+
<distributionManagement>
41+
<snapshotRepository>
42+
<id>ossrh</id>
43+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
44+
</snapshotRepository>
45+
<repository>
46+
<id>ossrh</id>
47+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
48+
</repository>
49+
</distributionManagement>
50+
51+
<properties>
52+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
53+
<java.version>1.8</java.version>
54+
<spring.boot.version>1.4.0.RELEASE</spring.boot.version>
55+
<maven.compiler.source>${java.version}</maven.compiler.source>
56+
<maven.compiler.target>${java.version}</maven.compiler.target>
57+
</properties>
58+
59+
<profiles>
60+
<profile>
61+
<id>release</id>
62+
<build>
63+
<plugins>
64+
<plugin>
65+
<groupId>org.apache.maven.plugins</groupId>
66+
<artifactId>maven-source-plugin</artifactId>
67+
<version>2.2.1</version>
68+
<executions>
69+
<execution>
70+
<id>attach-sources</id>
71+
<goals>
72+
<goal>jar-no-fork</goal>
73+
</goals>
74+
</execution>
75+
</executions>
76+
</plugin>
77+
<plugin>
78+
<groupId>org.apache.maven.plugins</groupId>
79+
<artifactId>maven-javadoc-plugin</artifactId>
80+
<version>2.9.1</version>
81+
<executions>
82+
<execution>
83+
<id>attach-javadocs</id>
84+
<goals>
85+
<goal>jar</goal>
86+
</goals>
87+
</execution>
88+
</executions>
89+
</plugin>
90+
<plugin>
91+
<groupId>org.apache.maven.plugins</groupId>
92+
<artifactId>maven-gpg-plugin</artifactId>
93+
<version>1.5</version>
94+
<executions>
95+
<execution>
96+
<id>sign-artifacts</id>
97+
<phase>verify</phase>
98+
<goals>
99+
<goal>sign</goal>
100+
</goals>
101+
</execution>
102+
</executions>
103+
</plugin>
104+
</plugins>
105+
</build>
106+
</profile>
107+
</profiles>
108+
109+
<build>
110+
<plugins>
111+
<plugin>
112+
<groupId>org.apache.maven.plugins</groupId>
113+
<artifactId>maven-release-plugin</artifactId>
114+
<version>2.5</version>
115+
<configuration>
116+
<autoVersionSubmodules>true</autoVersionSubmodules>
117+
<useReleaseProfile>false</useReleaseProfile>
118+
<releaseProfiles>release</releaseProfiles>
119+
<goals>deploy</goals>
120+
</configuration>
121+
</plugin>
122+
</plugins>
123+
</build>
124+
125+
126+
</project>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package hackerrank.algorithms.arraysandsorting;
2+
3+
import java.util.Scanner;
4+
5+
/**
6+
* Created by IntelliJ IDEA.
7+
* User: ramswaroop
8+
* Date: 3/1/15
9+
* Time: 8:58 PM
10+
* To change this template go to Preferences | IDE Settings | File and Code Templates
11+
*/
12+
public class InsertionSort1 {
13+
14+
static void insertIntoSorted(int[] ar) {
15+
int V = ar[ar.length - 1], i = ar.length - 2;
16+
17+
for (; i >= 0; i--) {
18+
if (V < ar[i]) {
19+
ar[i + 1] = ar[i];
20+
} else {
21+
break;
22+
}
23+
printArray(ar);
24+
}
25+
26+
ar[i + 1] = V;
27+
printArray(ar);
28+
}
29+
30+
/* Tail starts here */
31+
public static void main(String[] args) {
32+
Scanner in = new Scanner(System.in);
33+
int s = in.nextInt();
34+
int[] ar = new int[s];
35+
for (int i = 0; i < s; i++) {
36+
ar[i] = in.nextInt();
37+
}
38+
insertIntoSorted(ar);
39+
}
40+
41+
private static void printArray(int[] ar) {
42+
for (int n : ar) {
43+
System.out.print(n + " ");
44+
}
45+
System.out.println("");
46+
}
47+
48+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package hackerrank.algorithms.arraysandsorting;
2+
3+
import java.util.Scanner;
4+
5+
/**
6+
* Created by IntelliJ IDEA.
7+
* User: ramswaroop
8+
* Date: 3/1/15
9+
* Time: 9:42 PM
10+
* To change this template go to Preferences | IDE Settings | File and Code Templates
11+
*/
12+
public class InsertionSort2 {
13+
14+
static void insertionSortPart2(int[] ar) {
15+
for (int i = 1; i < ar.length; i++) {
16+
int V = ar[i], j;
17+
/**
18+
* keep shifting no.s to right until
19+
* right place for insertion(of V) is found
20+
*/
21+
for (j = i - 1; j >= 0 && ar[j] > V; j--) {
22+
ar[j + 1] = ar[j];
23+
}
24+
ar[j + 1] = V;
25+
printArray(ar);
26+
}
27+
}
28+
29+
public static void main(String[] args) {
30+
Scanner in = new Scanner(System.in);
31+
int s = in.nextInt();
32+
int[] ar = new int[s];
33+
for (int i = 0; i < s; i++) {
34+
ar[i] = in.nextInt();
35+
}
36+
insertionSortPart2(ar);
37+
38+
}
39+
40+
private static void printArray(int[] ar) {
41+
for (int n : ar) {
42+
System.out.print(n + " ");
43+
}
44+
System.out.println("");
45+
}
46+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package hackerrank.algorithms.arraysandsorting;
2+
3+
import java.util.Arrays;
4+
import java.util.Scanner;
5+
6+
/**
7+
* Created by IntelliJ IDEA.
8+
* User: ramswaroop
9+
* Date: 3/1/15
10+
* Time: 3:38 PM
11+
* To change this template go to Preferences | IDE Settings | File and Code Templates
12+
*/
13+
public class IntroTutorial {
14+
static int search(int searchVal, int[] arr) {
15+
return Arrays.binarySearch(arr, searchVal);
16+
}
17+
18+
public static void main(String[] a) {
19+
Scanner in = new Scanner(System.in);
20+
21+
int searchVal = in.nextInt();
22+
int arrSize = in.nextInt();
23+
int[] arr = new int[arrSize];
24+
// as nextInt() doesn't read new line character
25+
in.nextLine();
26+
String next = in.nextLine();
27+
String[] next_split = next.split(" ");
28+
29+
for (int _a_i = 0; _a_i < arrSize; _a_i++) {
30+
arr[_a_i] = Integer.parseInt(next_split[_a_i]);
31+
}
32+
33+
System.out.print(search(searchVal, arr));
34+
}
35+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package hackerrank.algorithms.arraysandsorting;
2+
3+
import java.util.Scanner;
4+
5+
/**
6+
* Created by IntelliJ IDEA.
7+
* User: ramswaroop
8+
* Date: 3/2/15
9+
* Time: 3:26 PM
10+
* To change this template go to Preferences | IDE Settings | File and Code Templates
11+
*/
12+
public class LoopInvariant {
13+
14+
public static void insertionSort(int[] A) {
15+
for (int i = 1; i < A.length; i++) {
16+
int value = A[i];
17+
int j = i - 1;
18+
while (j >= 0 && A[j] > value) {
19+
A[j + 1] = A[j];
20+
j = j - 1;
21+
}
22+
A[j + 1] = value;
23+
}
24+
25+
printArray(A);
26+
}
27+
28+
29+
static void printArray(int[] ar) {
30+
for (int n : ar) {
31+
System.out.print(n + " ");
32+
}
33+
}
34+
35+
public static void main(String[] args) {
36+
Scanner in = new Scanner(System.in);
37+
int n = in.nextInt();
38+
int[] ar = new int[n];
39+
for (int i = 0; i < n; i++) {
40+
ar[i] = in.nextInt();
41+
}
42+
insertionSort(ar);
43+
}
44+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package hackerrank.algorithms.arraysandsorting;
2+
3+
import java.util.Scanner;
4+
5+
/**
6+
* Created by IntelliJ IDEA.
7+
* User: ramswaroop
8+
* Date: 3/2/15
9+
* Time: 5:13 PM
10+
* To change this template go to Preferences | IDE Settings | File and Code Templates
11+
*/
12+
public class QuickSort1 {
13+
14+
static void partition(int[] ar) {
15+
int pivot = ar[0], j = 0;
16+
int[] arCopy = ar.clone();
17+
18+
for (int i = 0; i < arCopy.length; i++) {
19+
if (arCopy[i] < pivot) ar[j++] = arCopy[i];
20+
}
21+
for (int i = 0; i < arCopy.length; i++) {
22+
if (arCopy[i] >= pivot) ar[j++] = arCopy[i];
23+
}
24+
printArray(ar);
25+
}
26+
27+
static void printArray(int[] ar) {
28+
for (int n : ar) {
29+
System.out.print(n + " ");
30+
}
31+
System.out.println("");
32+
}
33+
34+
public static void main(String[] args) {
35+
Scanner in = new Scanner(System.in);
36+
int n = in.nextInt();
37+
int[] ar = new int[n];
38+
for (int i = 0; i < n; i++) {
39+
ar[i] = in.nextInt();
40+
}
41+
partition(ar);
42+
}
43+
}

0 commit comments

Comments
 (0)