├── 3.FunctionsAndArrays ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.jdt.core.prefs │ └── org.jboss.ide.eclipse.as.core.prefs └── src │ ├── anyBaseAddition │ ├── Main.java │ └── README.md │ ├── anyBaseMultiplication │ ├── Main.java │ └── README.md │ ├── anyBaseSubtraction │ ├── Main.java │ └── README.md │ ├── anyBaseToAnyBase │ ├── Main.java │ └── README.md │ ├── anyBaseToDecimal │ ├── Main.java │ └── README.md │ ├── barchart │ ├── Main.java │ └── README.md │ ├── decimalToAnyBase │ ├── Main.java │ └── README.md │ ├── differenceofTwoArrays │ ├── Main.java │ └── README.md │ ├── digitfrequency │ ├── Main.java │ └── README.md │ ├── findElementInArray │ ├── Main.java │ └── README.md │ ├── inverseOfAnArray │ ├── Main.java │ └── README.md │ ├── reverseAnArray │ ├── Main.java │ └── README.md │ ├── rotateAnArray │ ├── Main.java │ └── README.md │ ├── spanOfArray │ ├── Main.java │ └── README.md │ ├── subArrayProblem │ ├── Main.java │ └── README.md │ ├── subsetsOfArray │ ├── Main.java │ └── README.md │ └── sumOfTwoArrays │ ├── Main.java │ └── README.md ├── BinarySearch,2d,Strings,IToRecursion.pdf ├── Dynamic Programming.pdf ├── Getting Started ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.jdt.core.prefs │ └── org.jboss.ide.eclipse.as.core.prefs └── src │ ├── .gitignore │ ├── countdigits │ ├── CountingDigits.java │ └── README.md │ ├── displayingdigits │ ├── DisplayDigits.java │ └── README.md │ ├── gcdandlcm │ ├── Main.java │ └── README.md │ ├── grading │ └── system │ │ ├── Grading.java │ │ └── README.md │ ├── inversenumber │ ├── Inverse.java │ └── README.md │ ├── isaNumberprime │ ├── Numberprime.java │ └── README.md │ ├── primefactorization │ ├── Main.java │ └── README.md │ ├── printallprimestilln │ ├── PrintAllPrimes.java │ └── README.md │ ├── printfirstnfibonacci │ ├── FibonacciTillN.java │ └── README.md │ ├── pythogtriplet │ ├── README.md │ └── Triplet.java │ ├── reversedigits │ ├── README.md │ └── Reverse.java │ ├── rotatinganumber │ ├── README.md │ └── Rotating.java │ ├── thecuriouscaseofbenjaminbulbs │ ├── Bulbs.java │ └── README.md │ └── z │ └── pattern │ ├── README.md │ └── Z.java ├── Patterns ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.jdt.core.prefs │ └── org.jboss.ide.eclipse.as.core.prefs └── src │ ├── Pattern1 │ ├── Main.java │ └── README.md │ ├── Pattern2 │ ├── Main.java │ └── README.md │ ├── Pattern3 │ ├── Main.java │ └── README.md │ ├── Pattern4 │ ├── Main.java │ └── README.md │ ├── Pattern5 │ ├── Main.java │ └── README.md │ ├── Pattern6 │ ├── Main.java │ └── README.md │ ├── Pattern7 │ ├── Main.java │ └── README.md │ ├── Pattern8 │ ├── Main.java │ └── README.md │ ├── Pattern9 │ ├── Main.java │ └── README.md │ ├── Patterns10 │ ├── Main.java │ └── README.md │ ├── Patterns11 │ ├── Main.java │ └── README.md │ ├── Patterns12 │ ├── Main.java │ └── README.md │ ├── Patterns13 │ ├── Main.java │ └── README.md │ ├── Patterns14 │ ├── Main.java │ └── README.md │ ├── Patterns15 │ ├── Main.java │ └── README.md │ ├── Patterns16 │ ├── Main.java │ └── README.md │ ├── Patterns17 │ ├── Main.java │ └── README.md │ ├── Patterns18 │ ├── Main.java │ └── README.md │ ├── Patterns19 │ ├── Main.java │ └── README.md │ └── Patterns20 │ ├── Main.java │ └── README.md ├── README.md ├── Time Complexity.pdf ├── pepcoding-notes-till-arrays_.pdf └── recursion-arraylist-on the way-backtracking.pdf /3.FunctionsAndArrays/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | 3.FunctionsAndArrays 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.8 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.release=disabled 12 | org.eclipse.jdt.core.compiler.source=1.8 13 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/.settings/org.jboss.ide.eclipse.as.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.jboss.ide.eclipse.as.core.singledeployable.deployableList= 3 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/anyBaseAddition/Main.java: -------------------------------------------------------------------------------- 1 | package anyBaseAddition; 2 | 3 | import java.util.*; 4 | 5 | public class Main{ 6 | 7 | public static void main(String[] args) { 8 | Scanner scn = new Scanner(System.in); 9 | int b = scn.nextInt(); 10 | int n1 = scn.nextInt(); 11 | int n2 = scn.nextInt(); 12 | 13 | int d = getSum(b, n1, n2); 14 | System.out.println(d); 15 | } 16 | 17 | public static int getSum(int b, int n1, int n2){ 18 | // write ur code here 19 | int c=0; 20 | int ans=0; 21 | int pow=1; 22 | while(n1!=0 || n2!=0 || c>0){ 23 | int rem1=n1%10; 24 | int rem2=n2%10; 25 | int temp=rem1+rem2+c; 26 | ans+=(temp%b)*pow; 27 | c=temp/b; 28 | pow=pow*10; 29 | n1=n1/10; 30 | n2=n2/10; 31 | } 32 | return ans; 33 | } 34 | } -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/anyBaseAddition/README.md: -------------------------------------------------------------------------------- 1 | # Any Base Addition 2 | 3 | 1. You are given a base b. 4 | 2. You are given two numbers n1 and n2 of base b. 5 | 3. You are required to add the two numbes and print their value in base b. 6 | ## Input Format 7 | A base b 8 | A number n1 9 | A number n2 10 | ## Output Format 11 | A number representing the sum of n1 and n2 in base b. 12 | 13 | ## Constraints 14 | 2 <= b <= 10
15 | 0 <= n1 <= 256
16 | 0 <= n2 <= 256
17 | ## Sample Input 18 | 8
19 | 777
20 | 1
21 | Sample Output 22 | 1000 23 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/anyBaseMultiplication/Main.java: -------------------------------------------------------------------------------- 1 | package anyBaseMultiplication; 2 | 3 | import java.util.*; 4 | 5 | public class Main{ 6 | 7 | public static void main(String[] args) { 8 | Scanner scn = new Scanner(System.in); 9 | int b = scn.nextInt(); 10 | int n1 = scn.nextInt(); 11 | int n2 = scn.nextInt(); 12 | 13 | int d = getProduct(b, n1, n2); 14 | System.out.println(d); 15 | } 16 | 17 | public static int getProduct(int b, int n1, int n2){ 18 | // write your code here 19 | int ans=0; 20 | int pow=1; 21 | 22 | while(n2>0){ 23 | int temp=n2%10; 24 | int value=getSingleProduct(b,n1,temp); 25 | ans=getProductSum(b,ans,value*pow); 26 | pow=pow*10; 27 | n2=n2/10; 28 | 29 | } 30 | return ans; 31 | 32 | } 33 | 34 | public static int getSingleProduct(int b,int n1,int d){ 35 | 36 | int pow=1; 37 | int ans=0; 38 | int c=0; 39 | while(n1>0 || c>0){ 40 | int rem=n1%10; 41 | int temp=(rem*d)+c; 42 | ans+=(temp%b)*pow; 43 | c=temp/b; 44 | n1=n1/10; 45 | pow=pow*10; 46 | } 47 | return ans; 48 | 49 | 50 | 51 | } 52 | public static int getProductSum(int b,int n1,int n2){ 53 | int pow=1; 54 | int ans=0; 55 | int c=0; 56 | while(n1>0 || n2>0 || c>0){ 57 | int rem1=n1%10; 58 | int rem2=n2%10; 59 | int temp=rem1+rem2+c; 60 | ans+=(temp%b)*pow; 61 | c=temp/b; 62 | pow=pow*10; 63 | n1=n1/10; 64 | n2=n2/10; 65 | } 66 | 67 | return ans; 68 | 69 | 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/anyBaseMultiplication/README.md: -------------------------------------------------------------------------------- 1 | # Any Base Multiplication 2 | 3 | 1. You are given a base b. 4 | 2. You are given two numbers n1 and n2 of base b. 5 | 3. You are required to multiply n1 and n2 and print the value. 6 | 7 | ## Input Format 8 | A base b 9 | A number n1 10 | A number n2 11 | ## Output Format 12 | A number of base b equal in value to n2 * n1. 13 | 14 | ## Constraints 15 | 2 <= b <= 10
16 | 0 <= n1 <= 10000
17 | 0 <= n2 <= 10000
18 | ## Sample Input 19 | 5
20 | 1220
21 | 31
22 | ## Sample Output 23 | 43320 24 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/anyBaseSubtraction/Main.java: -------------------------------------------------------------------------------- 1 | package anyBaseSubtraction; 2 | 3 | import java.util.*; 4 | 5 | public class Main{ 6 | 7 | public static void main(String[] args) { 8 | Scanner scn = new Scanner(System.in); 9 | int b = scn.nextInt(); 10 | int n1 = scn.nextInt(); 11 | int n2 = scn.nextInt(); 12 | 13 | int d = getDifference(b, n1, n2); 14 | System.out.println(d); 15 | } 16 | 17 | public static int getDifference(int b, int n1, int n2){ 18 | // write your code here 19 | int c=0; 20 | int pow=1; 21 | int ans=0; 22 | while(n1>0 || n2>0 || c!=0){ 23 | 24 | int rem1=n1%10; 25 | int rem2=n2%10; 26 | rem2=rem2+c; 27 | if(rem2>=rem1){ 28 | c=0; 29 | ans+=(rem2-rem1)*pow; 30 | } 31 | else{ 32 | c=-1; 33 | ans+=(rem2+b-rem1)*pow; 34 | } 35 | n1=n1/10; 36 | n2=n2/10; 37 | pow=pow*10; 38 | 39 | 40 | 41 | } 42 | return ans; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/anyBaseSubtraction/README.md: -------------------------------------------------------------------------------- 1 | # Any Base Subtraction 2 | 3 | 1. You are given a base b. 4 | 2. You are given two numbers n1 and n2 of base b. 5 | 3. You are required to subtract n1 from n2 and print the value. 6 | ## Input Format 7 | A base b 8 | A number n1 9 | A number n2 10 | ## Output Format 11 | A number of base b equal in value to n2 - n1. 12 | 13 | ## Constraints 14 | 2 <= b <= 10
15 | 0 <= n1 <= 256
16 | n1 <= n2 <= 256
17 | ## Sample Input 18 | 8
19 | 1
20 | 100
21 | ## Sample Output 22 | 77 23 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/anyBaseToAnyBase/Main.java: -------------------------------------------------------------------------------- 1 | package anyBaseToAnyBase; 2 | 3 | import java.util.*; 4 | 5 | public class Main{ 6 | 7 | public static void main(String[] args) { 8 | Scanner scn = new Scanner(System.in); 9 | int n = scn.nextInt(); 10 | int sourceBase = scn.nextInt(); 11 | int destBase= scn.nextInt(); 12 | int interm=n; 13 | int pow=0; 14 | int rev=0; 15 | int ans=0; 16 | int temp=1; 17 | while(interm!=0){ 18 | int rem=interm%10; 19 | interm=interm/10; 20 | rev=rev+(int)Math.pow(sourceBase,pow)*rem; 21 | pow++; 22 | } 23 | while(rev!=0){ 24 | int rem=rev%destBase; 25 | rev=rev/destBase; 26 | ans+=rem*temp; 27 | temp=temp*10; 28 | 29 | } 30 | System.out.println(ans); 31 | } 32 | } -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/anyBaseToAnyBase/README.md: -------------------------------------------------------------------------------- 1 | # Any Base To Any Base 2 | 3 | 1. You are given a number n. 4 | 2. You are given a base b1. n is a number on base b. 5 | 3. You are given another base b2. 6 | 4. You are required to convert the number n of base b1 to a number in base b2. 7 | 8 | ## Input Format 9 | A number n 10 | A base b1 11 | A base b2 12 | ## Output Format 13 | A number of base b2 equal in value to n of base b1. 14 | 15 | ## Constraints 16 | 0 <= n <= 512
17 | 2 <= b1 <= 10
18 | 2 <= b2 <= 10
19 | ## Sample Input 20 | 111001
21 | 2
22 | 3
23 | ## Sample Output 24 | 2010 25 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/anyBaseToDecimal/Main.java: -------------------------------------------------------------------------------- 1 | package anyBaseToDecimal; 2 | 3 | import java.util.*; 4 | 5 | public class Main{ 6 | 7 | public static void main(String[] args) { 8 | Scanner scn = new Scanner(System.in); 9 | int n = scn.nextInt(); 10 | int b = scn.nextInt(); 11 | int d = getValueIndecimal(n, b); 12 | System.out.println(d); 13 | } 14 | 15 | public static int getValueIndecimal(int n, int b){ 16 | // write your code here 17 | int pow=0; 18 | int rev=0; 19 | while(n!=0){ 20 | int rem=n%10; 21 | n=n/10; 22 | rev=rev+(int)Math.pow(b,pow)*rem; 23 | pow++; 24 | 25 | } 26 | return rev; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/anyBaseToDecimal/README.md: -------------------------------------------------------------------------------- 1 | # Any Base To Decimal 2 | 3 | 1. You are given a number n. 4 | 2. You are given a base b. n is a number on base b. 5 | 3. You are required to convert the number n into its corresponding value in decimal number system. 6 | ## Input Format 7 | A number n
8 | A base b
9 | ## Output Format 10 | A decimal number representing corresponding value of n in base b. 11 | 12 | ## Constraints 13 | 0 <= d <= 1000000000
14 | 2 <= b <= 10
15 | 16 | ## Sample Input 17 | 111001
18 | 2
19 | ## Sample Output 20 | 57 21 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/barchart/Main.java: -------------------------------------------------------------------------------- 1 | package barchart; 2 | 3 | import java.io.*; 4 | import java.util.*; 5 | 6 | public class Main{ 7 | 8 | public static void main(String[] args) throws Exception { 9 | // write your code here 10 | Scanner scn = new Scanner(System.in); 11 | int n = scn.nextInt(); 12 | int a[] = new int[n]; 13 | 14 | for(int i = 0;i < n;i++){ 15 | a[i] = scn.nextInt(); 16 | } 17 | 18 | int max=a[0]; 19 | for(int i=0;imax){ 21 | max=a[i]; 22 | } 23 | } 24 | 25 | for(int i=max;i>0;i--){ 26 | for(int j=0;j=i){ 28 | System.out.print("*\t"); 29 | } 30 | else{ 31 | System.out.print("\t"); 32 | } 33 | } 34 | System.out.println(); 35 | } 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/barchart/README.md: -------------------------------------------------------------------------------- 1 | # Bar Chart 2 | 3 | 1. You are given a number n, representing the size of array a. 4 | 2. You are given n numbers, representing elements of array a. 5 | 3. You are required to print a bar chart representing value of arr a. 6 | 7 | ## Input Format 8 | A number n
9 | n1
10 | n2
11 | .. n number of elements
12 | ## Output Format 13 | A bar chart of asteriks representing value of array a 14 | 15 | ## Constraints 16 | 1 <= n <= 30
17 | 0 <= n1, n2, .. n elements <= 10
18 | ## Sample Input 19 | 5
20 | 3
21 | 1
22 | 0
23 | 7
24 | 5
25 | ## Sample Output 26 | Get Bar graph with number of stars presnt in the array 27 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/decimalToAnyBase/Main.java: -------------------------------------------------------------------------------- 1 | package decimalToAnyBase; 2 | 3 | import java.util.*; 4 | 5 | public class Main{ 6 | 7 | public static void main(String[] args) { 8 | Scanner scn = new Scanner(System.in); 9 | int n = scn.nextInt(); 10 | int b = scn.nextInt(); 11 | int dn = getValueInBase(n, b); 12 | System.out.println(dn); 13 | } 14 | 15 | public static int getValueInBase(int n, int b){ 16 | // write code here 17 | int temp=1; 18 | int rv=0; 19 | while(n!=0){ 20 | int rem=n%b; 21 | n=n/b; 22 | 23 | rv=rv+(rem*temp); 24 | 25 | temp=temp*10; 26 | 27 | 28 | } 29 | return rv; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/decimalToAnyBase/README.md: -------------------------------------------------------------------------------- 1 | # Decimal To Any Base 2 | 3 | 1. You are given a decimal number n. 4 | 2. You are given a base b. 5 | 3. You are required to convert the number n into its corresponding value in base b. 6 | ## Input Format 7 | A number n 8 | A base b 9 | ## Output Format 10 | A number representing corresponding value of n in number system of base b 11 | 12 | ## Constraints 13 | 0 <= d <= 512
14 | 2 <= b <= 10
15 | 16 | ## Sample Input 17 | 57
18 | 2
19 | ## Sample Output 20 | 111001 21 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/differenceofTwoArrays/Main.java: -------------------------------------------------------------------------------- 1 | package differenceofTwoArrays; 2 | 3 | import java.io.*; 4 | import java.util.*; 5 | 6 | public class Main{ 7 | 8 | public static void main(String[] args) throws Exception { 9 | // write your code here 10 | Scanner scn = new Scanner(System.in); 11 | int n1=scn.nextInt(); 12 | int a[] = new int[n1]; 13 | for(int i=0;i=n2){ 23 | maxSize=n1; 24 | } 25 | else{ 26 | maxSize=n2; 27 | } 28 | int ans[]= new int[maxSize]; 29 | int c=0; 30 | 31 | for(int i=n1-1,j=n2-1,k=maxSize-1;k>=0;i--,j--,k--){ 32 | int res=0; 33 | 34 | int temp=i>=0?a[i]:0; 35 | if(b[j]+c>=temp){ 36 | res=b[j]+c-temp; 37 | c=0; 38 | } 39 | else{ 40 | res=b[j]+c+10-temp; 41 | c=-1; 42 | } 43 | ans[k]=res; 44 | } 45 | int count=0; 46 | for(int i=0;i 4 | 2. You are given n1 numbers, representing elements of array a1.
5 | 3. You are given a number n2, representing the size of array a2.
6 | 4. You are given n2 numbers, representing elements of array a2.
7 | 5. The two arrays represent digits of two numbers.
8 | 6. You are required to find the difference of two numbers represented by two arrays and print the arrays. a2 - a1
9 | 10 | ## Assumption -
11 | number represented by a2 is greater. 12 | ## Input Format 13 | A number n1
14 | n1 number of elements line separated
15 | A number n2
16 | n2 number of elements line separated
17 | ## Output Format 18 | A number representing difference of two numbers (a2 - a1), represented by two arrays. 19 | 20 | ## Constraints 21 | 1 <= n1, n2 <= 100
22 | 0 <= a1[i], a2[i] < 10
23 | number reresented by a1 is smaller than number represented by a2
24 | ## Sample Input 25 | 3
26 | 2
27 | 6
28 | 7
29 | 4
30 | 1
31 | 0
32 | 0
33 | 0
34 | ## Sample Output 35 | 7
36 | 3
37 | 3
38 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/digitfrequency/Main.java: -------------------------------------------------------------------------------- 1 | package digitfrequency; 2 | 3 | import java.util.*; 4 | 5 | public class Main { 6 | 7 | public static void main(String[] args) { 8 | Scanner scn = new Scanner(System.in); 9 | int n = scn.nextInt(); 10 | int d = scn.nextInt(); 11 | int f = getDigitFrequency(n, d); 12 | System.out.println(f); 13 | } 14 | 15 | public static int getDigitFrequency(int n, int d) { 16 | // write code here 17 | int count=0; 18 | while(n!=0){ 19 | int r=n%10; 20 | if(r==d) 21 | count++; 22 | n=n/10; 23 | } 24 | return count; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/digitfrequency/README.md: -------------------------------------------------------------------------------- 1 | # Digit Frequency 2 | 3 | 1. You are given a number n. 4 | 2. You are given a digit d. 5 | 3. You are required to calculate the frequency of digit d in number n. 6 | 7 | ## Input Format 8 | A number n 9 | A digit d 10 | ## Output Format 11 | A number representing frequency of digit d in number n 12 | 13 | ## Constraints 14 | 0 <= n <= 10^9
15 | 0 <= d <= 9
16 | 17 | ## Sample Input 18 | 994543234
19 | 4
20 | ## Sample Output 21 | 3 22 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/findElementInArray/Main.java: -------------------------------------------------------------------------------- 1 | package findElementInArray; 2 | 3 | import java.io.*; 4 | import java.util.*; 5 | 6 | public class Main{ 7 | 8 | public static void main(String[] args) throws Exception { 9 | // write your code here 10 | Scanner scn = new Scanner(System.in); 11 | int n = scn.nextInt(); 12 | int a[] = new int[n]; 13 | for( int i = 0; i < n; i++ ){ 14 | a[i] = scn.nextInt(); 15 | } 16 | int d = scn.nextInt(); 17 | for( int i = 0; i < n; i++){ 18 | if( a[i] == d ){ 19 | System.out.print(i); 20 | return; 21 | } 22 | } 23 | System.out.println("-1"); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/findElementInArray/README.md: -------------------------------------------------------------------------------- 1 | # Find Element In An Array 2 | 3 | 1.You are given a number n, representing the size of array a.
4 | 2.You are given n distinct numbers, representing elements of array a.
5 | 3. You are given another number d.
6 | 4. You are required to check if d number exists in the array a and at what index (0 based). If found print the index, otherwise print -1.
7 | ## Input Format 8 | A number n 9 | n1 10 | n2 11 | .. n number of elements 12 | A number d 13 | ## Output Format 14 | A number representing index at which d is found in array a and -1 if not found 15 | 16 | ## Constraints 17 | 1 <= n <= 10^7
18 | -10^9 <= n1, n2
19 | .. n elements <= 10^9
20 | -10^9 <= d <= 10^9
21 | ## Sample Input 22 | 6
23 | 15
24 | 30
25 | 40
26 | 4
27 | 11
28 | 9
29 | 40
30 | ## Sample Output 31 | 2 32 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/inverseOfAnArray/Main.java: -------------------------------------------------------------------------------- 1 | package inverseOfAnArray; 2 | 3 | import java.io.*; 4 | import java.util.*; 5 | 6 | public class Main{ 7 | public static void display(int[] a){ 8 | StringBuilder sb = new StringBuilder(); 9 | 10 | for(int val: a){ 11 | sb.append(val + "\n"); 12 | } 13 | System.out.println(sb); 14 | } 15 | 16 | public static int[] inverse(int[] a){ 17 | // write your code here 18 | 19 | int b[]=new int[a.length]; 20 | for(int i=0;i 17 | 4
18 | 0
19 | 2
20 | 3
21 | 1
22 | ## Sample Output 23 | 1
24 | 4
25 | 2
26 | 3
27 | 0
28 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/reverseAnArray/Main.java: -------------------------------------------------------------------------------- 1 | package reverseAnArray; 2 | 3 | import java.io.*; 4 | import java.util.*; 5 | 6 | public class Main{ 7 | public static void display(int[] a){ 8 | StringBuilder sb = new StringBuilder(); 9 | 10 | for(int val: a){ 11 | sb.append(val + " "); 12 | } 13 | System.out.println(sb); 14 | } 15 | 16 | public static void reverse(int[] a){ 17 | // write your code here 18 | int s=0; 19 | int e=a.length-1; 20 | while(s 13 | -10^9 <= a[i] <= 10^9
14 | ## Sample Input 15 | 5
16 | 1
17 | 2
18 | 3
19 | 4
20 | 5
21 | ## Sample Output 22 | 5 4 3 2 1 23 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/rotateAnArray/Main.java: -------------------------------------------------------------------------------- 1 | package rotateAnArray; 2 | 3 | import java.io.*; 4 | import java.util.*; 5 | 6 | public class Main{ 7 | public static void display(int[] a){ 8 | StringBuilder sb = new StringBuilder(); 9 | 10 | for(int val: a){ 11 | sb.append(val + " "); 12 | } 13 | System.out.println(sb); 14 | } 15 | 16 | public static void rotate(int[] a, int k){ 17 | // write your code here 18 | k = k % a.length; 19 | 20 | if(k<0){ 21 | k=k+a.length; 22 | } 23 | 24 | reverseArray(a,0,a.length-1-k); 25 | 26 | reverseArray(a,a.length-k,a.length-1); 27 | 28 | reverseArray(a,0,a.length-1); 29 | 30 | 31 | 32 | } 33 | 34 | public static void reverseArray(int a[],int left,int right){ 35 | while(left 16 | -10^9 <= a[i], k <= 10^9
17 | ## Sample Input 18 | 5
19 | 1
20 | 2
21 | 3
22 | 4
23 | 5
24 | 3
25 | ## Sample Output 26 | 3 4 5 1 2 27 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/spanOfArray/Main.java: -------------------------------------------------------------------------------- 1 | package spanOfArray; 2 | 3 | import java.io.*; 4 | import java.util.*; 5 | 6 | public class Main{ 7 | 8 | public static void main(String[] args) throws Exception { 9 | // write your code here 10 | Scanner scn= new Scanner(System.in); 11 | int n = scn.nextInt(); 12 | int a[] = new int[n]; 13 | for(int i = 0; i < n; i++){ 14 | a[i]=scn.nextInt(); 15 | } 16 | int max = a[0]; 17 | for(int i = 0; i < n; i++){ 18 | if(a[i] > max){ 19 | max = a[i]; 20 | } 21 | } 22 | 23 | int min = a[0]; 24 | for(int i = 0; i < n; i++){ 25 | if(a[i] < min ){ 26 | min = a[i]; 27 | } 28 | } 29 | int ans = max - min; 30 | System.out.println(ans); 31 | 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/spanOfArray/README.md: -------------------------------------------------------------------------------- 1 | # Span Of Array 2 | 3 | 1. You are given a number n, representing the count of elements. 4 | 2. You are given n numbers. 5 | 3. You are required to find the span of input. Span is defined as difference of maximum value and minimum value. 6 | ## Input Format 7 | A number n 8 | n1 9 | n2 10 | .. n number of elements 11 | ## Output Format 12 | A number representing max - min 13 | 14 | ## Constraints 15 | 1 <= n <= 10^4
16 | 0 <= n1, n2
17 | .. n elements <= 10 ^9
18 | ## Sample Input 19 | 6
20 | 15
21 | 30
22 | 40
23 | 4
24 | 11
25 | 9
26 | ## Sample Output 27 | 36 28 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/subArrayProblem/Main.java: -------------------------------------------------------------------------------- 1 | package subArrayProblem; 2 | 3 | import java.io.*; 4 | import java.util.*; 5 | 6 | public class Main{ 7 | 8 | public static void main(String[] args) throws Exception { 9 | // write your code here 10 | Scanner scn = new Scanner(System.in); 11 | int n = scn.nextInt(); 12 | int a[] = new int[n]; 13 | for(int i = 0;i < n; i++){ 14 | a[i] = scn.nextInt(); 15 | } 16 | 17 | for(int i= 0; i 9 | n1
10 | n2
11 | .. n number of elements
12 | ## Output Format 13 | [Tab separated elements of subarray]
14 | ..
15 | All subarrays
16 | 17 | ## Constraints 18 | 1 <= n <= 10
19 | 0 <= n1, n2
20 | .. n elements <= 10 ^9
21 | ## Sample Input 22 | 3
23 | 10
24 | 20
25 | 30
26 | ## Sample Output 27 | 10
28 | 10 20
29 | 10 20 30
30 | 20
31 | 20 30
32 | 30
33 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/subsetsOfArray/Main.java: -------------------------------------------------------------------------------- 1 | package subsetsOfArray; 2 | 3 | import java.io.*; 4 | import java.util.*; 5 | 6 | public class Main{ 7 | 8 | public static void main(String[] args) throws Exception { 9 | // write your code here 10 | Scanner scn = new Scanner(System.in); 11 | int n = scn.nextInt(); 12 | int a[] = new int[n]; 13 | for(int i = 0; i < n; i++){ 14 | a[i]=scn.nextInt(); 15 | } 16 | 17 | int count = (int) Math.pow(2,n); 18 | 19 | for(int i=0;i0){ 26 | int q=bin/div; 27 | if(q==0) 28 | System.out.print("-\t"); 29 | else 30 | System.out.print(a[ele]+"\t"); 31 | bin=bin%div; 32 | div=div/10; 33 | ele++; 34 | } 35 | 36 | System.out.println(); 37 | 38 | } 39 | 40 | } 41 | 42 | public static int decimaltoBinary(int n){ 43 | int ans=0; 44 | int pow=1; 45 | while(n!=0){ 46 | int r=n%2; 47 | n=n/2; 48 | ans+=r*pow; 49 | pow=pow*10; 50 | 51 | } 52 | return ans; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/subsetsOfArray/README.md: -------------------------------------------------------------------------------- 1 | # Subsets Of Array 2 | 3 | 1. You are given a number n, representing the count of elements. 4 | 2. You are given n numbers. 5 | 3. You are required to print all subsets of arr. Each subset should be 6 | on separate line. For more clarity check out sample input and output. 7 | ## Input Format 8 | A number n
9 | n1
10 | n2
11 | .. n number of elements 12 | ## Output Format 13 | [Tab separated elements of subset]
14 | ..
15 | All subsets
16 | 17 | ## Constraints 18 | 1 <= n <= 10
19 | 0 <= n1, n2, .. n elements <= 10^3
20 | ## Sample Input 21 | 3
22 | 10
23 | 20
24 | 30
25 | ## Sample Output 26 | - - - 27 | - - 30 28 | - 20 - 29 | - 20 30 30 | 10 - -
31 | 10 - 30
32 | 10 20 -
33 | 10 20 30
34 | -------------------------------------------------------------------------------- /3.FunctionsAndArrays/src/sumOfTwoArrays/Main.java: -------------------------------------------------------------------------------- 1 | package sumOfTwoArrays; 2 | 3 | import java.io.*; 4 | import java.util.*; 5 | 6 | public class Main{ 7 | 8 | public static void main(String[] args) throws Exception { 9 | // write your code here 10 | Scanner scn = new Scanner(System.in); 11 | int n1 = scn.nextInt(); 12 | int a[]= new int[n1]; 13 | for( int i = 0; i < n1; i++){ 14 | a[i] = scn.nextInt(); 15 | } 16 | int n2 = scn.nextInt(); 17 | int b[] = new int[n2]; 18 | for( int i = 0; i < n2; i++){ 19 | b[i] = scn.nextInt(); 20 | } 21 | int maxSize=0; 22 | if(n1>=n2){ 23 | maxSize=n1+1; 24 | } 25 | else{ 26 | maxSize=n2+1; 27 | } 28 | int ans[] = new int[maxSize]; 29 | int c = 0; 30 | for(int i = n1-1,j=n2-1,k=maxSize-1;k>=0;i--,j--,k--){ 31 | int sum=c; 32 | if(i>=0){ 33 | sum+=a[i]; 34 | } 35 | if(j>=0){ 36 | sum+=b[j]; 37 | } 38 | int add=sum%10; 39 | 40 | ans[k]=add; 41 | c=sum/10; 42 | } 43 | 44 | for(int i= 0;i 12 | n1 number of elements line separated
13 | A number n2
14 | n2 number of elements line separated
15 | ## Output Format 16 | A number representing sum of two numbers, represented by two arrays. 17 | 18 | ## Constraints 19 | 1 <= n1, n2 <= 100
20 | 0 <= a1[i], a2[i] < 10
21 | ## Sample Input 22 | 5
23 | 3
24 | 1
25 | 0
26 | 7
27 | 5
28 | 6
29 | 1
30 | 1
31 | 1
32 | 1
33 | 1
34 | 1
35 | ## Sample Output 36 | 1
37 | 4
38 | 2
39 | 1
40 | 8
41 | 6
42 | -------------------------------------------------------------------------------- /BinarySearch,2d,Strings,IToRecursion.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cvsaikrishna/pepcoding/5bd4f87189e67951cfdc923a6a88d5e6d55cdfb9/BinarySearch,2d,Strings,IToRecursion.pdf -------------------------------------------------------------------------------- /Dynamic Programming.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cvsaikrishna/pepcoding/5bd4f87189e67951cfdc923a6a88d5e6d55cdfb9/Dynamic Programming.pdf -------------------------------------------------------------------------------- /Getting Started/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Getting Started/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /Getting Started/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.Getting Started 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /Getting Started/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.8 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.release=disabled 12 | org.eclipse.jdt.core.compiler.source=1.8 13 | -------------------------------------------------------------------------------- /Getting Started/.settings/org.jboss.ide.eclipse.as.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.jboss.ide.eclipse.as.core.singledeployable.deployableList= 3 | -------------------------------------------------------------------------------- /Getting Started/src/.gitignore: -------------------------------------------------------------------------------- 1 | /gcdandlcm/ 2 | -------------------------------------------------------------------------------- /Getting Started/src/countdigits/CountingDigits.java: -------------------------------------------------------------------------------- 1 | package countdigits; 2 | 3 | import java.util.Scanner; 4 | 5 | public class CountingDigits { 6 | 7 | public static void main(String[] args) { 8 | 9 | Scanner sc=new Scanner(System.in); 10 | int n=sc.nextInt(); 11 | int count=0; 12 | while(n!=0) { 13 | count++; 14 | n=n/10; 15 | } 16 | System.out.println(count); 17 | sc.close(); 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Getting Started/src/countdigits/README.md: -------------------------------------------------------------------------------- 1 | # Count Digits In A Number 2 | 3 | 1. You've to count the number of digits in a number. 4 | 2. Take as input "n", the number for which the digits has to be counted. 5 | 3. Print the digits in that number. 6 | 7 | ## Input Format 8 | "n" where n is any integer. 9 | ## Output Format 10 | "d" where d is the number of digits in the number "n" 11 | 12 | ## Constraints 13 | 1 <= n < 10^9 14 | ## Sample Input 15 | 65784383 16 | ## Sample Output 17 | 8 18 | -------------------------------------------------------------------------------- /Getting Started/src/displayingdigits/DisplayDigits.java: -------------------------------------------------------------------------------- 1 | package displayingdigits; 2 | 3 | import java.util.Scanner; 4 | 5 | public class DisplayDigits { 6 | 7 | public static void main(String[] args) { 8 | 9 | Scanner sc=new Scanner(System.in); 10 | int n=sc.nextInt(); 11 | String a=Integer.toString(n); 12 | int leng = a.length(); 13 | int div=(int)Math.pow(10, leng-1); 14 | while(div>0) { 15 | 16 | int q=n/div; 17 | System.out.println(q); 18 | n = n % div; 19 | div=div/10; 20 | } 21 | sc.close(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Getting Started/src/displayingdigits/README.md: -------------------------------------------------------------------------------- 1 | # Digits Of A Number 2 | 3 | 1. You've to display the digits of a number. 4 | 2. Take as input "n", the number for which digits have to be displayed. 5 | 3. Print the digits of the number line-wise. 6 | 7 | ## Input Format 8 | "n" where n is any integer. 9 | ## Output Format 10 | d1 11 | d2 12 | d3 13 | ... digits of the number 14 | 15 | ## Constraints 16 | 1 <= n < 10^9 17 | ## Sample Input 18 | 65784383 19 | ## Sample Output 20 | 6 21 | 5 22 | 7 23 | 8 24 | 4 25 | 3 26 | 8 27 | 3 28 | -------------------------------------------------------------------------------- /Getting Started/src/gcdandlcm/Main.java: -------------------------------------------------------------------------------- 1 | package gcdandlcm; 2 | 3 | import java.util.*; 4 | 5 | public class Main{ 6 | 7 | public static void main(String[] args) { 8 | // write your code here 9 | Scanner sc=new Scanner(System.in); 10 | int n1=sc.nextInt(); 11 | int n2=sc.nextInt(); 12 | int div=n1; 13 | int dvd=n2; 14 | 15 | while(dvd%div!=0){ 16 | int r=dvd%div; 17 | dvd=div; 18 | div=r; 19 | } 20 | int gcd=div; 21 | int lcm=n1*n2/gcd; 22 | System.out.println(gcd); 23 | System.out.println(lcm); 24 | } 25 | } -------------------------------------------------------------------------------- /Getting Started/src/gcdandlcm/README.md: -------------------------------------------------------------------------------- 1 | # Gcd And Lcm 2 | 3 | 1. You are required to print the Greatest Common Divisor (GCD) of two numbers. 4 | 2. You are also required to print the Lowest Common Multiple (LCM) of the same numbers. 5 | 3. Take input "num1" and "num2" as the two numbers. 6 | 4. Print their GCD and LCM. 7 | ## Input Format 8 | num1 9 | num2 10 | .. the numbers whose GCD and LCM we have to find. 11 | 12 | ## Output Format 13 | a 14 | b 15 | .. where 'a' and 'b' are the GCD and LCM respectively. 16 | 17 | ## Constraints 18 | 2 <= n <= 10^9 19 | ## Sample Input 20 | 36 21 | 24 22 | ## Sample Output 23 | 12 24 | 72 25 | -------------------------------------------------------------------------------- /Getting Started/src/grading/system/Grading.java: -------------------------------------------------------------------------------- 1 | package grading.system; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Grading { 6 | 7 | public static void main(String[] args) { 8 | Scanner sc=new Scanner(System.in); 9 | int marks=sc.nextInt(); 10 | 11 | if(marks>90) { 12 | System.out.println("excellent"); 13 | } 14 | else if(marks>80) { 15 | System.out.println("good"); 16 | } 17 | else if(marks>70) { 18 | System.out.println("fair"); 19 | } 20 | else if(marks>60) { 21 | System.out.println("meets expectations"); 22 | } 23 | else { 24 | System.out.println("below par"); 25 | } 26 | sc.close(); 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Getting Started/src/grading/system/README.md: -------------------------------------------------------------------------------- 1 | # Grading System 2 | 3 | 1. You are given as input marks of a student. 4 | 2. Display an appropriate message based on the following rules: 5 | 2.1 for marks above 90, print excellent. 6 | 2.2 for marks above 80 and less than equal to 90, print good. 7 | 2.3 for marks above 70 and less than equal to 80, print fair. 8 | 2.4 for marks above 60 and less than equal to 70, print meets expectations. 9 | 2.5 for marks less than equal to 60, print below par. 10 | 11 | Note -> Only change the code in area after - // code here 12 | 13 | ## Input Format 14 | Input is handled for you and provided as variable marks 15 | 16 | ## Output Format 17 | Appropriate message as per student's marks 18 | ## Constraints 19 | No constraints 20 | ## Sample Input 21 | 92 22 | ## Sample Output 23 | excellent 24 | -------------------------------------------------------------------------------- /Getting Started/src/inversenumber/Inverse.java: -------------------------------------------------------------------------------- 1 | package inversenumber; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Inverse { 6 | 7 | public static void main(String[] args) { 8 | Scanner sc = new Scanner(System.in); 9 | 10 | int n = sc.nextInt(); 11 | int i=1; 12 | int sum=0; 13 | while(n>0) { 14 | int r=n%10; 15 | sum=sum+(i*(int)Math.pow(10, r-1)); 16 | n=n/10; 17 | i++; 18 | } 19 | System.out.println(sum); 20 | 21 | sc.close(); 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Getting Started/src/inversenumber/README.md: -------------------------------------------------------------------------------- 1 | # Inverse Of A Number 2 | 1. You are given a number following certain constraints. 3 | 2. The key constraint is if the number is 5 digits long, it'll contain all the digits from 1 to 5 without missing any and without repeating any. e.g. 23415 is a 5 digit long number containing all digits from 1 to 5 without missing and repeating any digit from 1 to 5.Take a look at few other valid numbers - 624135, 81456273 etc.Here are a few invalid numbers - 139, 7421357 etc. 4 | 3. The inverse of a number is defined as the number created by interchanging the face value and index of digits of number.e.g. for 426135 (reading from right to left, 5 is in place 1, 3 is in place 2, 1 is in place 3, 6 is in place 4, 2 is in place 5 and 4 is in place 6), the inverse will be 416253 (reading from right to left, 3 is in place 1, 5 is in place 2,2 is in place 3, 6 is in place 4, 1 is in place 5 and 4 is in place 6) More examples - inverse of 2134 is 1243 and inverse of 24153 is 24153 5 | 4. Take as input number "n", assume that the number will follow constraints. 6 | 5. Print it's inverse. 7 | 8 | ## Input Format 9 | "n" where n is any integer, following constraints defined above. 10 | ## Output Format 11 | "i", the inverted number 12 | 13 | ## Constraints 14 | 1 <= n < 10^8, and follwing other constraints defined above. 15 | ## Sample Input 16 | 28346751 17 | ## Sample Output 18 | 73425681 19 | -------------------------------------------------------------------------------- /Getting Started/src/isaNumberprime/Numberprime.java: -------------------------------------------------------------------------------- 1 | package isaNumberprime; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Numberprime { 6 | 7 | public static void main(String[] args) { 8 | Scanner sc = new Scanner(System.in); 9 | int cases=sc.nextInt(); 10 | for(int i=0;i 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Patterns/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /Patterns/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | 2.Patterns 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /Patterns/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.8 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.release=disabled 12 | org.eclipse.jdt.core.compiler.source=1.8 13 | -------------------------------------------------------------------------------- /Patterns/.settings/org.jboss.ide.eclipse.as.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.jboss.ide.eclipse.as.core.singledeployable.deployableList= 3 | -------------------------------------------------------------------------------- /Patterns/src/Pattern1/Main.java: -------------------------------------------------------------------------------- 1 | package Pattern1; 2 | 3 | import java.util.*; 4 | 5 | public class Main { 6 | 7 | public static void main(String[] args) { 8 | Scanner scn = new Scanner(System.in); 9 | 10 | // write ur code here 11 | 12 | int n=scn.nextInt(); 13 | for(int i=1;i<=n;i++){ 14 | for(int j=1;j<=i;j++){ 15 | System.out.print("*\t"); 16 | } 17 | System.out.println(); 18 | } 19 | 20 | } 21 | } -------------------------------------------------------------------------------- /Patterns/src/Pattern1/README.md: -------------------------------------------------------------------------------- 1 | # Pattern 1 2 | 3 | ## Input Format 4 | A number n 5 | ## Output Format 6 | ![image](https://user-images.githubusercontent.com/46378797/122221855-4ff5e800-cecf-11eb-97ff-bed08457063b.png) 7 | 8 | ## Constraints 9 | 1 <= n <= 100 10 | ## Sample Input 11 | 2 12 | ## Sample Output 13 | * 14 | * * 15 | -------------------------------------------------------------------------------- /Patterns/src/Pattern2/Main.java: -------------------------------------------------------------------------------- 1 | package Pattern2; 2 | 3 | import java.util.*; 4 | 5 | public class Main { 6 | 7 | public static void main(String[] args) { 8 | Scanner scn = new Scanner(System.in); 9 | 10 | // write ur code here 11 | 12 | int n = scn.nextInt(); 13 | 14 | for(int i=n;i>0;i--){ 15 | for(int j=i;j>0;j--){ 16 | System.out.print("*\t"); 17 | } 18 | System.out.println(); 19 | } 20 | 21 | 22 | } 23 | } -------------------------------------------------------------------------------- /Patterns/src/Pattern2/README.md: -------------------------------------------------------------------------------- 1 | # Pattern 2 2 | 3 | 1. You are given a number n. 4 | 2. You've to create a pattern of * and separated by tab as shown in output format. 5 | 6 | ## Input Format 7 | A number n 8 | ## Output Format 9 | ![image](https://user-images.githubusercontent.com/46378797/122222180-a6632680-cecf-11eb-88ab-3b4ee04d358e.png) 10 | 11 | ## Constraints 12 | 1 <= n <= 100 13 | ## Sample Input 14 | 5 15 | ## Sample Output 16 | ![image](https://user-images.githubusercontent.com/46378797/122222180-a6632680-cecf-11eb-88ab-3b4ee04d358e.png) 17 | -------------------------------------------------------------------------------- /Patterns/src/Pattern3/Main.java: -------------------------------------------------------------------------------- 1 | package Pattern3; 2 | 3 | import java.util.*; 4 | 5 | public class Main { 6 | 7 | public static void main(String[] args) { 8 | Scanner scn = new Scanner(System.in); 9 | 10 | // write ur code here 11 | 12 | int n = scn.nextInt(); 13 | int stars = 1; 14 | int spaces = n-1; 15 | 16 | for(int i=0;i 15 | 2 3
16 | 4 5 6
17 | 7 8 9 10
18 | 11 12 13 14 15
19 | -------------------------------------------------------------------------------- /Patterns/src/Patterns12/Main.java: -------------------------------------------------------------------------------- 1 | package Patterns12; 2 | 3 | import java.util.*; 4 | 5 | public class Main { 6 | 7 | public static void main(String[] args) { 8 | Scanner scn = new Scanner(System.in); 9 | 10 | // write ur code here 11 | int n = scn.nextInt(); 12 | int a=0,b=1; 13 | for(int i=1;i<=n;i++){ 14 | for(int j=1;j<=i;j++){ 15 | System.out.print(a+"\t"); 16 | int c=a+b; 17 | a=b; 18 | b=c; 19 | } 20 | System.out.println(); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Patterns/src/Patterns12/README.md: -------------------------------------------------------------------------------- 1 | # Pattern 12 2 | 3 | 1. You are given a number n. 4 | 2. You've to create a pattern as shown in output format. 5 | ## Input Format 6 | A number n 7 | ## Output Format 8 | ![image](https://user-images.githubusercontent.com/46378797/122226375-8c2b4780-ced3-11eb-8a12-589586046f1a.png) 9 | 10 | ## Constraints 11 | 1 <= n <= 5 12 | ## Sample Input 13 | 5 14 | ## Sample Output 15 | 0
16 | 1 1
17 | 2 3 5
18 | 8 13 21 34
19 | 55 89 144 233 377
20 | -------------------------------------------------------------------------------- /Patterns/src/Patterns13/Main.java: -------------------------------------------------------------------------------- 1 | package Patterns13; 2 | 3 | import java.util.*; 4 | public class Main{ 5 | public static void main(String[] args){ 6 | Scanner scn = new Scanner(System.in); 7 | 8 | //write your code here 9 | 10 | int n = scn.nextInt(); 11 | 12 | for(int i=0;i 17 | 1 1
18 | 1 2 1
19 | 1 3 3 1
20 | 1 4 6 4 1
21 | -------------------------------------------------------------------------------- /Patterns/src/Patterns14/Main.java: -------------------------------------------------------------------------------- 1 | package Patterns14; 2 | 3 | import java.util.*; 4 | 5 | public class Main { 6 | 7 | public static void main(String[] args) { 8 | Scanner scn = new Scanner(System.in); 9 | 10 | // write ur code here 11 | 12 | int n = scn.nextInt(); 13 | 14 | for(int i =1;i<=10;i++){ 15 | int k=i*n; 16 | System.out.println(n+" * "+i+" = "+k); 17 | 18 | } 19 | 20 | 21 | } 22 | } -------------------------------------------------------------------------------- /Patterns/src/Patterns14/README.md: -------------------------------------------------------------------------------- 1 | # Pattern 14 2 | 3 | 1. You are given a number n. 4 | 2. You've to write code to print it's multiplication table up to 10 in format given below. 5 | ## Input Format 6 | A number x 7 | ## Output Format 8 | ![image](https://user-images.githubusercontent.com/46378797/122226953-1378bb00-ced4-11eb-95c7-ea75c1f478f2.png) 9 | 10 | ## Constraints 11 | 1 <= n <= 10 12 | ## Sample Input 13 | 3 14 | ## Sample Output 15 | 3 * 1 = 3
16 | 3 * 2 = 6
17 | 3 * 3 = 9
18 | 3 * 4 = 12
19 | 3 * 5 = 15
20 | 3 * 6 = 18
21 | 3 * 7 = 21
22 | 3 * 8 = 24
23 | 3 * 9 = 27
24 | 3 * 10 = 30
25 | -------------------------------------------------------------------------------- /Patterns/src/Patterns15/Main.java: -------------------------------------------------------------------------------- 1 | package Patterns15; 2 | 3 | import java.util.*; 4 | 5 | public class Main { 6 | 7 | public static void main(String[] args) { 8 | Scanner scn = new Scanner(System.in); 9 | 10 | // write ur code here 11 | 12 | int n = scn.nextInt(); 13 | int spaces = n/2; 14 | int stars=1; 15 | int count=1; 16 | for(int i=1;i<=n;i++){ 17 | int temp=count; 18 | for(int j=0;j=1;j--){ 26 | System.out.print(j+"\t"); 27 | } 28 | System.out.println(); 29 | stars++; 30 | spaces=spaces-2; 31 | 32 | } 33 | 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Patterns/src/Patterns16/README.md: -------------------------------------------------------------------------------- 1 | # Pattern 16 2 | 3 | 1. You are given a number n. 4 | 2. You've to write code to print the pattern given in output format below 5 | 6 | ## Input Format 7 | A number n 8 | ## Output Format 9 | ![image](https://user-images.githubusercontent.com/46378797/122227686-bd584780-ced4-11eb-86a0-48a708ff1221.png) 10 | 11 | ## Constraints 12 | 1 <= n <= 10 13 | ## Sample Input 14 | 4 15 | ## Sample Output 16 | ![image](https://user-images.githubusercontent.com/46378797/122227686-bd584780-ced4-11eb-86a0-48a708ff1221.png) 17 | -------------------------------------------------------------------------------- /Patterns/src/Patterns17/Main.java: -------------------------------------------------------------------------------- 1 | package Patterns17; 2 | 3 | import java.util.*; 4 | 5 | public class Main { 6 | 7 | public static void main(String[] args) { 8 | Scanner scn = new Scanner(System.in); 9 | 10 | // write ur code here 11 | 12 | int n = scn.nextInt(); 13 | int os=n/2; 14 | int stars=1; 15 | int oos=n/2; 16 | 17 | for(int i=1;i<=n;i++){ 18 | for(int j=0;j1){ 22 | if(j>0&&j n / 2 + 1 && i= n / 2 + 1){ 51 | System.out.print("*\t"); 52 | } 53 | else{ 54 | System.out.print("\t"); 55 | } 56 | 57 | } 58 | 59 | 60 | 61 | 62 | } 63 | 64 | 65 | System.out.println(); 66 | } 67 | 68 | } 69 | } -------------------------------------------------------------------------------- /Patterns/src/Patterns19/README.md: -------------------------------------------------------------------------------- 1 | # Pattern 19 2 | 3 | 1. You are given a number n. 4 | 2. You've to write code to print the pattern given in output format below 5 | 6 | ## Input Format 7 | A number n 8 | ## Output Format 9 | ![image](https://user-images.githubusercontent.com/46378797/122230166-04473c80-ced7-11eb-87eb-12a59376ec8a.png) 10 | 11 | 12 | ## Constraints 13 | 1 <= n <= 10 14 | Also, n is odd. 15 | ## Sample Input 16 | 5 17 | ## Sample Output 18 | ![image](https://user-images.githubusercontent.com/46378797/122230166-04473c80-ced7-11eb-87eb-12a59376ec8a.png) 19 | -------------------------------------------------------------------------------- /Patterns/src/Patterns20/Main.java: -------------------------------------------------------------------------------- 1 | package Patterns20; 2 | 3 | import java.util.*; 4 | 5 | public class Main { 6 | 7 | public static void main(String[] args) { 8 | Scanner scn = new Scanner(System.in); 9 | 10 | // write ur code here 11 | 12 | int n = scn.nextInt(); 13 | 14 | for(int i = 1; i <= n; i++){ 15 | for(int j = 1; j <= n; j++){ 16 | if(j == 1 || j == n){ 17 | System.out.print("*\t"); 18 | } 19 | else if(i > n/2 && (i == j || i+j == n + 1)){ 20 | System.out.print("*\t"); 21 | } 22 | else{ 23 | System.out.print("\t"); 24 | } 25 | 26 | } 27 | System.out.println(); 28 | } 29 | 30 | } 31 | } -------------------------------------------------------------------------------- /Patterns/src/Patterns20/README.md: -------------------------------------------------------------------------------- 1 | # Pattern 20 2 | 3 | 1. You are given a number n. 4 | 2. You've to write code to print the pattern given in output format below. 5 | ## Input Format 6 | A number n 7 | ## Output Format 8 | ![image](https://user-images.githubusercontent.com/46378797/122230514-59834e00-ced7-11eb-801a-4414dbefd705.png) 9 | 10 | ## Constraints 11 | 1 <= n <= 10 12 | Also, n is odd. 13 | ## Sample Input 14 | 5 15 | ## Sample Output 16 | ![image](https://user-images.githubusercontent.com/46378797/122230520-5a1be480-ced7-11eb-9e95-955af000fd4c.png) 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pepcoding -------------------------------------------------------------------------------- /Time Complexity.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cvsaikrishna/pepcoding/5bd4f87189e67951cfdc923a6a88d5e6d55cdfb9/Time Complexity.pdf -------------------------------------------------------------------------------- /pepcoding-notes-till-arrays_.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cvsaikrishna/pepcoding/5bd4f87189e67951cfdc923a6a88d5e6d55cdfb9/pepcoding-notes-till-arrays_.pdf -------------------------------------------------------------------------------- /recursion-arraylist-on the way-backtracking.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cvsaikrishna/pepcoding/5bd4f87189e67951cfdc923a6a88d5e6d55cdfb9/recursion-arraylist-on the way-backtracking.pdf --------------------------------------------------------------------------------