├── README.md ├── bubble_sort.java ├── Numbering_in_words.java ├── vowels_Question.java ├── Stack.java └── Maximize_Colours.java /README.md: -------------------------------------------------------------------------------- 1 | # JAVA_Coding 2 | Java practice codes 3 | 4 | I started learning the java programming and then later deceided to recorde the codes that I learn on a daily basis. 5 | So let's get started to make the 365 days streak in the github. 6 | -------------------------------------------------------------------------------- /bubble_sort.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Main{ 3 | public static void main(String args[]){ 4 | Scanner s=new Scanner(System.in); 5 | System.out.println("Enter Size : "); 6 | int n=s.nextInt(); 7 | int a[]=new int[n]; 8 | int max=0; 9 | System.out.println("Enter elements : "); 10 | for(int i=0;imax ) 13 | max=a[i]; 14 | } 15 | max++; 16 | int a1[]=new int[max]; 17 | for(int i=0;i 0) { 15 | System.out.print(h[a / 100] + " "); 16 | } 17 | a %= 100; 18 | if (a >= 10 && a < 20) { 19 | System.out.print(t1[a - 10]); 20 | else if (a >= 20) { 21 | System.out.print(t2[a / 10 - 2] + " "); 22 | a %= 10; 23 | } 24 | if (a > 0) { 25 | System.out.print(o[a]); 26 | } 27 | System.out.println(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vowels_Question.java: -------------------------------------------------------------------------------- 1 | // Input: 2 | // 5 3 | // 5 4 | // apple 5 | // 15 6 | // schtschurowskia 7 | // 6 8 | // polish 9 | // 5 10 | // tryst 11 | // 3 12 | // cry 13 | 14 | // output 15 | // YES 16 | // NO 17 | // YES 18 | // NO 19 | // YES 20 | 21 | 22 | 23 | import java.util.*; 24 | import java.lang.*; 25 | import java.io.*; 26 | 27 | class vowels_Question 28 | { 29 | public static void main (String[] args) throws java.lang.Exception 30 | { 31 | // your code goes here 32 | Scanner scanner = new Scanner(System.in); 33 | int T = scanner.nextInt(); 34 | while (T-- > 0) { 35 | int N = scanner.nextInt(); 36 | String S = scanner.next(); 37 | String vowels = "aeiou"; 38 | int consonantStreak = 0; 39 | boolean isEasy = true; 40 | for (int i = 0; i < S.length(); i++) { 41 | char currentChar = S.charAt(i); 42 | if (vowels.indexOf(currentChar) != -1) { 43 | consonantStreak = 0; 44 | } else { 45 | consonantStreak++; 46 | } 47 | if (consonantStreak >= 4) { 48 | isEasy = false; 49 | break; 50 | } 51 | } 52 | if (isEasy) { 53 | System.out.println("YES"); 54 | } else { 55 | System.out.println("NO"); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Stack.java: -------------------------------------------------------------------------------- 1 | package Project; 2 | public class Stack_operation { 3 | int[] stack; 4 | int size; 5 | int top; 6 | Stack_operation(int size){ 7 | this.size=size; 8 | stack = new int[size]; 9 | top=-1; 10 | } 11 | public void push(int val) { 12 | if(top==size-1) 13 | System.out.println("Stack overflow"); 14 | else 15 | stack[++top]=val; 16 | } 17 | public int pop() { 18 | if(top==-1) { 19 | System.out.println("Stack underflow"); 20 | return -1; 21 | } 22 | else 23 | return stack[top--]; 24 | } 25 | public void peek() { 26 | if(top==-1) 27 | System.out.println("Stack underflow"); 28 | else 29 | System.out.println(stack[top]); 30 | } 31 | public void update(int pos,int val) { 32 | if(top==-1) 33 | System.out.println("Stack underflow"); 34 | if(pos>size || pos<0 || pos>top) 35 | System.out.println("Unable to insert"); 36 | if(pos 0) { 21 | primary++; 22 | red--; 23 | } 24 | if(green > 0) { 25 | primary++; 26 | green--; 27 | } 28 | if(blue > 0) { 29 | primary++; 30 | blue--; 31 | } 32 | if(red > 0 && green > 0) { 33 | secondary++; 34 | red--; 35 | green--; 36 | } 37 | if(red > 0 && blue > 0) { 38 | secondary++; 39 | red--; 40 | blue--; 41 | } 42 | if(blue > 0 && green > 0) { 43 | secondary++; 44 | blue--; 45 | green--; 46 | } 47 | return primary + secondary; 48 | } 49 | public static void main(String[] args) { 50 | Scanner sc = new Scanner(System.in); 51 | int size = sc.nextInt(); 52 | int res[] = new int[size]; 53 | for(int i = 0;i < size;i++) { 54 | int red = sc.nextInt(); 55 | int green = sc.nextInt(); 56 | int blue = sc.nextInt(); 57 | res[i] = colors(red, green, blue); 58 | } 59 | for(int ans : res) 60 | System.out.println(ans); 61 | } 62 | } 63 | --------------------------------------------------------------------------------