Skip to content

Commit 8553dea

Browse files
commit
1 parent d1d1b0a commit 8553dea

File tree

9 files changed

+73
-0
lines changed

9 files changed

+73
-0
lines changed

TrainingProblems/CombinationNumbers.java renamed to ArrayBasedProblems/CombinationNumbers.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package ArrayBasedProblems;
12
import java.util.Scanner;
23

34
public class CombinationNumbers {

TrainingProblems/CountingSubsequence.java renamed to ArrayBasedProblems/CountingSubsequence.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package ArrayBasedProblems;
12
public class CountingSubsequence {
23
public static void main(String[] args) {
34

TrainingProblems/LargestSumContiguousSubarray.java renamed to ArrayBasedProblems/LargestSumContiguousSubarray.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package ArrayBasedProblems;
12
//time complexity O(n3) cubic
23

34
public class LargestSumContiguousSubarray {

TrainingProblems/LargestSumOfSubsequence.java renamed to ArrayBasedProblems/LargestSumOfSubsequence.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package ArrayBasedProblems;
12
public class LargestSumOfSubsequence {
23
public static void main(String[] args) {
34
int a[] = { 1, 2, 3, 4, 5 }, n = 5, count = (1 << n) - 1;

TrainingProblems/SubSequenceInArray.java renamed to ArrayBasedProblems/SubSequenceInArray.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package ArrayBasedProblems;
12
public class SubSequenceInArray {
23
public static void main(String[] args) {
34
int a[]={5,3,1,6,2},sumOfSquence=6,n=a.length,total=(1<<n)-1,count=0;

TrainingProblems/AdjacentStringSwap.java renamed to StringBasedProblems/AdjacentStringSwap.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
package StringBasedProblems;
12
public class AdjacentStringSwap {
23
public static void main(String[] args) {
34
String org="new project";
5+
int j=0;
6+
for(int i=0;i<org.length();i++){}
7+
48

59
}
610

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package StringBasedProblems;
2+
import java.util.Scanner;
3+
4+
public class CinemaCharacter {
5+
public static void main(String[] args) {
6+
Scanner sc=new Scanner(System.in);
7+
String s=sc.next();
8+
char a[]=s.toCharArray();
9+
int n=a.length;
10+
for(int i=1;i<n;i++){
11+
int j=i-1;
12+
char temp=a[i];
13+
while(j>=0 && temp<a[j])
14+
{
15+
a[j+1]=a[j];
16+
j--;
17+
}
18+
a[j+1]=temp;
19+
}
20+
System.out.println(String.valueOf(a));
21+
22+
int count=1,p=0;
23+
char temp=a[0];
24+
for(int i=0;i<n-1;i++){
25+
if(a[i]==a[i+1])
26+
count++;
27+
else
28+
count=1;
29+
if(count>p){
30+
temp=a[i];
31+
p=count;
32+
}
33+
}
34+
35+
System.out.println(temp);
36+
sc.close();
37+
}
38+
}
39+
40+
// testcase 1
41+
42+
// input
43+
44+
// ddcccdcaaa which character is more time appeared and less ASCII key value
45+
46+
// output
47+
48+
// c here c character is more time appeared
49+
50+
51+
52+
53+
54+
// testcase 2
55+
56+
//input
57+
58+
// aaaadddbbbb here a and b are equal times appeared but a is less ASCII value
59+
60+
//output
61+
62+
//a
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package StringBasedProblems;
12
//output
23
//tce jo++rpwen
34

TrainingProblems/SubSequenceInString.java renamed to StringBasedProblems/SubSequenceInString.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package StringBasedProblems;
12
public class SubSequenceInString {
23
public static void main(String[] args) {
34
String s="abcd";

0 commit comments

Comments
 (0)