This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class A{ | |
public int a; | |
//dfgdf | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssssss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dynamic_programming; | |
/** | |
* Calculate the Fibonacci numbers up to n. | |
* When calculated, any Fibonacci number <=n can be returned without recalculating. | |
* Class Contributors: Faisal Rahman | |
* @author Faisal Rahman | |
* | |
*/ | |
public class Fibonacci { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RemoveDuplicates | |
{ | |
public string removeDuplicates(string input) | |
{ | |
StringBuilder sb = new StringBuilder(input); | |
int index=0; | |
for (int i = 1; i<sb.Length; i++) | |
{ | |
if(sb[index]!=sb[i]){ | |
index++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Link: https://github.com/rfaisal/hellouniverse/blob/master/Java/src/strings/DancingSentence.java | |
public static String convert(String s){ | |
StringBuilder sb = new StringBuilder(s); | |
boolean dancingFlag=true; | |
for(int i=0;i<sb.length();i++){ | |
if(sb.charAt(i)==' ') | |
continue; | |
else if(dancingFlag) | |
sb.setCharAt(i, Character.toUpperCase(sb.charAt(i))); | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MultipleOf3And5 { | |
private int max; | |
public MultipleOf3And5(int max){ | |
this.max=max; | |
} | |
public int calculate(){ | |
int sum=0; | |
int j=1; | |
int i=15; | |
while(i<max){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LargestPrimeFactor { | |
private long num; | |
public LargestPrimeFactor(long num){ | |
this.num=num; | |
} | |
public long calculate(){ | |
for(long i=1;i<=num/2;i++) | |
if(num%i==0) | |
if(isPrime(num/i)) | |
return num/i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PalindromeMaker { | |
public String make(String baseString) throws Exception{ | |
int[] hash= new int[26]; | |
for(int i=0;i<baseString.length();i++){ | |
char ch=baseString.charAt(i); | |
if(ch<'A' || ch>'Z') throw new Exception("Wrong Input"); | |
hash[ch-'A']++; | |
} | |
boolean check=false; | |
StringBuilder begin=new StringBuilder(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Problem Link: http://codeforces.com/problemset/problem/6/C | |
* Alice = getDivideIndex(..)+1; | |
* Bob = arrayLength - Alice; | |
*/ | |
public class Codeforces6C { | |
private static int getDivideIndexRec(int[] arr, int i, int j, boolean isLeft){ | |
if(i==j){ | |
if(isLeft) return i-1; | |
else return i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AmountApproximation { | |
public static int approximate(int D, int p1, int p2){ | |
int max_p1=(int)(D/p1)+1; | |
int max_p2=(int)(D/p2)+1; | |
int min=Integer.MAX_VALUE; | |
for(int i=0;i<=max_p1;i++){ | |
for(int j=0;j<=max_p2;j++){ | |
int sum=p1*i+p2*j; | |
if(sum>=D && sum<min) | |
min=sum; |
OlderNewer