├── day 60 ├── day 61 ├── day 81 ├── day x ├── day 39 ├── day 83 ├── day 35 ├── day 76 ├── day 80 ├── README.md ├── day 82 ├── day 58 ├── day 28 ├── day 73 ├── day 79 ├── day 54 ├── day 37 ├── day 56 ├── day 9 ├── day 2 ├── day 68 ├── day 7 ├── day 71 ├── day 65 ├── day 17 ├── day 55 ├── day 4 ├── day 53 ├── day 52 ├── day 1 ├── day 5 ├── day 70 ├── day 72 ├── day 30 ├── day 18 ├── day 51 ├── day 11 ├── day 15 ├── day 77 ├── day 41 ├── day 59 ├── day 78 ├── day 19 ├── day 31 ├── day 57 ├── day 42 ├── day 38 ├── day 13 ├── day 21 ├── day 3 ├── day 10 ├── day 6 ├── day 69 ├── day 48 ├── day 25 ├── day 40 ├── day 64 ├── day 14 ├── day 27 ├── day 47 ├── day 74 ├── day 16 ├── day 26 ├── day 67 ├── day 32 ├── day 36 ├── day 29 ├── day 8 ├── day 45 ├── day 23 ├── day 63 ├── day 46 ├── day 50 ├── day 75 ├── day 12 ├── day 34 ├── day 62 ├── day 33 ├── day 49 ├── day 44 ├── day 20 ├── day 22 ├── day 66 ├── day 43 └── day 24 /day 60: -------------------------------------------------------------------------------- 1 | h -------------------------------------------------------------------------------- /day 61: -------------------------------------------------------------------------------- 1 | hi -------------------------------------------------------------------------------- /day 81: -------------------------------------------------------------------------------- 1 | ✨✨😄 -------------------------------------------------------------------------------- /day x: -------------------------------------------------------------------------------- 1 | hdhsj -------------------------------------------------------------------------------- /day 39: -------------------------------------------------------------------------------- 1 | hii 2 | -------------------------------------------------------------------------------- /day 83: -------------------------------------------------------------------------------- 1 | hijbhjm 2 | -------------------------------------------------------------------------------- /day 35: -------------------------------------------------------------------------------- 1 | angry mode 2 | -------------------------------------------------------------------------------- /day 76: -------------------------------------------------------------------------------- 1 | Star pattern 2 | 3 | -------------------------------------------------------------------------------- /day 80: -------------------------------------------------------------------------------- 1 | starting python 2 | ada pongada 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ![GitHub Streak](https://streak-stats.demolab.com?user=hariharan1009) 4 | -------------------------------------------------------------------------------- /day 82: -------------------------------------------------------------------------------- 1 | i wanna a cry................................................................................................ 2 | -------------------------------------------------------------------------------- /day 58: -------------------------------------------------------------------------------- 1 | Given an array of integer arr. Your task is to construct the linked list from arr & return the head of the linked list. 2 | 3 | class Solution { 4 | static Node constructLL(int arr[]) { 5 | // code here 6 | Node head=new Node(arr[0]); 7 | Node p=head; 8 | for(int i=1;i0;i--){ 12 | if(arr[i]!=arr[i-1]){ 13 | s=arr[i-1]; 14 | break; 15 | } 16 | } 17 | return s; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /day 37: -------------------------------------------------------------------------------- 1 | Blackjack 2 | Chef is playing a variant of Blackjack, where 3 numbers are drawn and each number 3 | lies between 1 and 10 (with both 1 and 10 inclusive). Chef wins the game when the sum 4 | of these 3 numbers is exactly 21. 5 | Given the first two numbers A and B, that have been drawn by Chef, what should be 3- 6 | rd number that should be drawn by the Chef in order to win the game? 7 | Note that it is possible that Chef cannot win the game, no matter what is the 3-rd 8 | number. In such cases, report -1 as the answer. 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /day 56: -------------------------------------------------------------------------------- 1 | Given an array of integer arr. Your task is to construct the linked list from arr & return the head of the linked list. 2 | 3 | Examples: 4 | 5 | Input: arr = [1, 2, 3, 4, 5] 6 | Output: LinkedList: 1->2->3->4->5 7 | class Solution { 8 | static Node constructLL(int arr[]) { 9 | // code here 10 | Node head=new Node(arr[0]); 11 | Node p=head; 12 | for(int i=1;i0){ 18 | int a=sc.nextInt(); 19 | int b=sc.nextInt(); 20 | int c=sc.nextInt(); 21 | System.out.println(a*b*c); 22 | n--; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /day 55: -------------------------------------------------------------------------------- 1 | Input: nums = [1,2,3,4,5,6,7], k = 3 2 | Output: [5,6,7,1,2,3,4] 3 | Explanation: 4 | rotate 1 steps to the right: [7,1,2,3,4,5,6] 5 | rotate 2 steps to the right: [6,7,1,2,3,4,5] 6 | rotate 3 steps to the right: [5,6,7,1,2,3,4] 7 | 8 | class Solution { 9 | public void rotate(int[] nums, int k) { 10 | k=k%nums.length; 11 | rev(nums,0,nums.length-1); 12 | rev(nums,0,k-1); 13 | rev(nums,k,nums.length-1); 14 | 15 | } 16 | public void rev(int[] nums,int x,int y){ 17 | while(x12){ 25 | h-=12; 26 | p=p.replace('A','P'); 27 | } 28 | System.out.printf("%02d:%02d %s",h,m,p); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /day 53: -------------------------------------------------------------------------------- 1 | Input: n = 5, arr[] = [2, 3, 2, 3, 5], p = 5 2 | Output: [0, 2, 2, 0, 1] 3 | 4 | 5 | class Solution { 6 | // Function to count the frequency of all elements from 1 to N in the array. 7 | public static void frequencyCount(int arr[], int N, int P) { 8 | // do modify in the given array 9 | int[] b=new int[P+1]; 10 | for(int i=0;i0){ 13 | int a=sc.nextInt(); 14 | if(a<=100){ 15 | System.out.println(a); 16 | } 17 | else if(1000){ 18 | int a=sc.nextInt(); 19 | int b=sc.nextInt(); 20 | System.out.println((4*a)+b); 21 | n--; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /day 51: -------------------------------------------------------------------------------- 1 | Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. 2 | Assume the environment does not allow you to store 64-bit integers (signed or unsigned). 3 | Example 1: 4 | Input: x = 123 5 | Output: 321 6 | Example 2: 7 | Input: x = -123 8 | Output: -321 9 | Example 3: 10 | Input: x = 120 11 | Output: 21 12 | 13 | class Solution { 14 | public int reverse(int x) { 15 | int r=0; 16 | int n=0; 17 | while(x!=0){ 18 | n=x%10; 19 | if(rInteger.MAX_VALUE/10){ 20 | return 0; 21 | } 22 | r=(r*10)+n; 23 | x/=10; 24 | 25 | } 26 | return r; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /day 11: -------------------------------------------------------------------------------- 1 | According to a recent survey, Biryani is the most ordered food. Chef wants to learn how to make world-class Biryani from a MasterChef. Chef will be required to attend the MasterChef's classes for 2 | X weeks, and the cost of classes per week is 3 | Y 4 | Y coins. What is the total amount of money that Chef will have to pay? 5 | SOLUTION: 6 | 7 | import java.util.*; 8 | import java.lang.*; 9 | import java.io.*; 10 | 11 | 12 | class Codechef 13 | { 14 | public static void main (String[] args) throws java.lang.Exception 15 | { 16 | // your code goes here 17 | Scanner sc=new Scanner(System.in); 18 | int n=sc.nextInt(); 19 | while(n>0){ 20 | int a=sc.nextInt(); 21 | int b=sc.nextInt(); 22 | System.out.println(a*b); 23 | n--; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /day 15: -------------------------------------------------------------------------------- 1 | Janmansh has to submit 3 assignments for Chingari before 10 pm and he starts to do the assignments at X pm. Each assignment takes him 1 hour to complete. 2 | Can you tell whether he'll be able to complete all assignments on time or not? 3 | 4 | SOLUTION: 5 | 6 | 7 | 8 | import java.util.*; 9 | import java.lang.*; 10 | import java.io.*; 11 | 12 | class Codechef 13 | { 14 | public static void main (String[] args) throws java.lang.Exception 15 | { 16 | // your code goes here 17 | Scanner sc=new Scanner(System.in); 18 | int n=sc.nextInt(); 19 | while(n>0){ 20 | int a=sc.nextInt(); 21 | if((10-a)>=3){ 22 | System.out.println("YES"); 23 | } 24 | else{ 25 | System.out.println("NO"); 26 | } 27 | n--; 28 | } 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /day 77: -------------------------------------------------------------------------------- 1 | Get Lowest Free 2 | Chef goes to the supermarket to buy some items. Luckily there's a sale going on under which Chef gets the following offer: 3 | 4 | If Chef buys 3 items then he gets the item (out of those 3 items) having the lowest price as free. 5 | Input 6 | 7 | 3 8 | 6 2 4 9 | 3 3 3 10 | 8 4 4 11 | output 12 | 10 13 | 6 14 | 12 15 | 16 | import java.util.*; 17 | import java.lang.*; 18 | import java.io.*; 19 | 20 | class Codechef 21 | { 22 | public static void main (String[] args) throws java.lang.Exception 23 | { 24 | // your code goes here 25 | Scanner sc=new Scanner(System.in); 26 | int n=sc.nextInt(); 27 | while(n-->0){ 28 | int a=sc.nextInt(); 29 | int b=sc.nextInt(); 30 | int c=sc.nextInt(); 31 | int d=Math.min(a,Math.min(b,c)); 32 | System.out.println(a+b+c-d); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /day 41: -------------------------------------------------------------------------------- 1 | X Jumps 2 | 3 | Chef is currently standing at stair 0 and he wants to reach stair numbered X. 4 | 5 | Chef can climb either Y steps or 1 step in one move. 6 | Find the minimum number of moves required by him to reach exactly the stair 7 | numbered X. 8 | 9 | import java.util.*; 10 | import java.lang.*; 11 | import java.io.*; 12 | 13 | class Codechef 14 | { 15 | public static void main (String[] args) throws java.lang.Exception 16 | { 17 | // your code goes here 18 | Scanner sc=new Scanner(System.in); 19 | int n=sc.nextInt(); 20 | while(n-->0){ 21 | int x=sc.nextInt(); 22 | int y=sc.nextInt(); 23 | int z=x%y; 24 | if(x%y==0){ 25 | System.out.println(x/y); 26 | } 27 | else{ 28 | System.out.println(z+(x/y)); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /day 59: -------------------------------------------------------------------------------- 1 | Given an integer K and a queue of integers, we need to reverse the order of the first K elements of the queue, leaving the other elements in the same relative order. 2 | Input: 3 | 5 3 4 | 1 2 3 4 5 5 | Output: 6 | 3 2 1 4 5 7 | Explanation: 8 | After reversing the given 9 | input from the 3rd position the resultant 10 | output will be 3 2 1 4 5. 11 | class GfG { 12 | // Function to reverse first k elements of a queue. 13 | public Queue modifyQueue(Queue q, int k) { 14 | // add code here. 15 | int n=q.size(); 16 | Stack s= new Stack<>(); 17 | 18 | for(int i=0;i0){ 19 | int a=sc.nextInt(); 20 | int b=sc.nextInt(); 21 | int c=sc.nextInt(); 22 | int sum=0; 23 | int co=0; 24 | while (a!=1) 25 | { 26 | a=a/2; 27 | co++; 28 | } 29 | for(int j=0;j modifyQueue(Queue q, int k) { 15 | // add code here. 16 | int n=q.size(); 17 | Stack s= new Stack<>(); 18 | 19 | for(int i=0;i0){ 20 | int n=sc.nextInt(); 21 | int m=sc.nextInt(); 22 | int k=sc.nextInt(); 23 | int a=m*k; 24 | if(n%(k*m)==0){ 25 | System.out.println(n/a); 26 | } 27 | else{ 28 | System.out.println((n/a)+1); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /day 38: -------------------------------------------------------------------------------- 1 | Distinct Colors 2 | 3 | There are N different types of colours numbered from 1 to N. Chef has Aj balls having 4 | colour i, (1 ≤ i ≤ N). 5 | 6 | Chef will arrange some boxes and put each ball in exactly one of those boxes. 7 | Find the minimum number of boxes Chef needs so that no box contains two balls of 8 | same colour. 9 | 10 | import java.util.*; 11 | import java.lang.*; 12 | import java.io.*; 13 | 14 | class Codechef 15 | { 16 | public static void main (String[] args) throws java.lang.Exception 17 | { 18 | // your code goes here 19 | Scanner sc=new Scanner(System.in); 20 | int n=sc.nextInt(); 21 | while(n-->0){ 22 | int a=sc.nextInt(); 23 | int x[]=new int[a]; 24 | for(int i=0;i0){ 26 | a=sc.nextInt(); 27 | b=sc.nextInt(); 28 | c=Math.floorDiv(a,6); 29 | ans=c; 30 | if (a%6>0){ 31 | ans+=1; 32 | } 33 | System.out.println(ans*b); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /day 21: -------------------------------------------------------------------------------- 1 | Minimum Pizzas 2 | Each pizza consists of 4 slices. There are N friends and each friend needs exactly X slices.Find the minimum number of pizzas they should order to satisfy their appetite. 3 | Input 4 | 4 5 | 1 5 6 | 2 6 7 | 4 3 8 | 3 5 9 | Output 10 | 2 11 | 3 12 | 3 13 | 4 14 | import java.util.*; 15 | import java.lang.*; 16 | import java.io.*; 17 | 18 | class Codechef 19 | { 20 | public static void main (String[] args) throws java.lang.Exception 21 | { 22 | // your code goes here 23 | Scanner sc=new Scanner(System.in); 24 | int n=sc.nextInt(); 25 | while(n>0){ 26 | int a=sc.nextInt(); 27 | int b=sc.nextInt(); 28 | int x=4; 29 | int c=(a*b)/x; 30 | if((a*b)%4!=0){ 31 | System.out.println(c+1); 32 | } 33 | else{ 34 | System.out.println(c); 35 | } 36 | n--; 37 | 38 | } 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /day 3: -------------------------------------------------------------------------------- 1 | Accept an integer A as the input. If A is a positive integer then print the first five multiples of the unit digit of A as the output. If A is a negative integer then print the first ten multiples of the unit digit of A as the output. 2 | Example Input/Output 1: 3 | Input: 4 | 46 5 | Output: 6 | 6 12 18 24 30 7 | Example Input/Output 2: 8 | Input: 9 | -53 10 | Output: 11 | 3 6 9 12 15 18 21 24 27 30 12 | 13 | 14 | 15 | import java.util.*; 16 | public class Hello { 17 | 18 | public static void main(String[] args) { 19 | //Your Code Here 20 | Scanner sc=new Scanner(System.in); 21 | int b=sc.nextInt(); 22 | if(b>=0){ 23 | int a=(b%10); 24 | for(int i=1;i<=5;i++){ 25 | System.out.print(a*i +" "); 26 | } 27 | } 28 | 29 | else { 30 | int c=(b%10) *(-1); 31 | for(int j=1;j<=10;j++){ 32 | System.out.print(c*j +" "); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /day 10: -------------------------------------------------------------------------------- 1 | In Chefland, everyone who earns strictly more than 2 | Y 3 | Y rupees per year, has to pay a tax to Chef. Chef has allowed a special scheme where you can invest any amount of money and claim exemption for it. 4 | Find the minimum amount of money you have to invest so that you don't have to pay taxes this year. 5 | 6 | 7 | Sample 1: 8 | Input 9 | 10 | 4 11 | 4 2 12 | 8 7 13 | 5 1 14 | 2 1 15 | Output: 16 | 2 17 | 1 18 | 4 19 | 1 20 | SOLUTION 21 | import java.util.*; 22 | import java.lang.*; 23 | import java.io.*; 24 | 25 | class Codechef 26 | { 27 | public static void main (String[] args) throws java.lang.Exception 28 | { 29 | // your code goes here 30 | Scanner sc=new Scanner(System.in); 31 | int n=sc.nextInt(); 32 | int a,b; 33 | while(n>0){ 34 | a=sc.nextInt(); 35 | b=sc.nextInt(); 36 | System.out.println(a-b); 37 | 38 | n--; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /day 6: -------------------------------------------------------------------------------- 1 | Chef defines a pair of positive integers (a, b) to be a Oneful Pair, if 2 | a+b+(ab) = 111 3 | For example, (1, 55) is a Oneful Pair, since 1+55+ (155) 56+55 = 111. 4 | But (1, 56) is not a Oneful Pair, since 1+56+(1.56)=57+56113 / 111. 5 | Given two positive integers a and b, output Yes if they are a Oneful Pair. And No 6 | otherwise. 7 | Input Format 8 | The only line of input contains two space-separated integers a and b. 9 | Output Format 10 | Output Yes, if (a, b) form a Oneful Pair. Output No if they do not. 11 | 12 | solution: 13 | 14 | import java.util.*; 15 | import java.lang.*; 16 | import java.io.*; 17 | class Codechef 18 | { 19 | public static void main (String[] args) 20 | { 21 | Scanner sc = new Scanner(System.in); 22 | int a = sc.nextInt(); 23 | int b = sc.nextInt(); 24 | int c=a+b+(a*b); 25 | if(c==111){ 26 | System.out.println("Yes"); 27 | } 28 | else{ 29 | System.out.println("No"); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /day 69: -------------------------------------------------------------------------------- 1 | Find whether the given number is amicable pair or not.(sum of factors of first number equals to the 2nd number as well as sum of factors of 2nd number equal to first number) 2 | 3 | 4 | 5 | import java.io.*; 6 | import java.util.*; 7 | import java.text.*; 8 | import java.math.*; 9 | import java.util.regex.*; 10 | 11 | public class Solution { 12 | public static int am(int n) { 13 | int s = 0; 14 | for (int i=1;i<=n/2;i++) { 15 | if (n%i==0) { 16 | s+=i; 17 | } 18 | } 19 | return s; 20 | } 21 | 22 | public static void main(String[] args) { 23 | Scanner sc = new Scanner(System.in); 24 | int a = sc.nextInt(); 25 | int b = sc.nextInt(); 26 | 27 | if (am(a)==b&&am(b)==a) { 28 | System.out.println("Amicable Pair"); 29 | } else { 30 | System.out.println("Not a Amicable Pair"); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /day 48: -------------------------------------------------------------------------------- 1 | 2 | Minimum number of coins 3 | 4 | Chef has infinite coins in denominations of rupees 5 and rupees 10. 5 | 6 | Find the minimum number of coins Chef needs, to pay exactly X rupees. If it is 7 | impossible to pay X rupees in denominations of rupees 5 and 10 only, print -1. 8 | 9 | 10 | 11 | import java.util.*; 12 | import java.lang.*; 13 | import java.io.*; 14 | 15 | class Codechef 16 | { 17 | public static void main (String[] args) throws java.lang.Exception 18 | { 19 | // your code goes here 20 | Scanner sc=new Scanner(System.in); 21 | int n=sc.nextInt(); 22 | while(n-->0){ 23 | int x=sc.nextInt(); 24 | if(x%10==0){ 25 | System.out.println(x/10); 26 | } 27 | else if(x%5==0){ 28 | System.out.println(x/5-x/10); 29 | } 30 | else{ 31 | System.out.println("-1"); 32 | } 33 | 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /day 25: -------------------------------------------------------------------------------- 1 | Election season has started in Chefland and the election commission wants to know the count of eligible voters. 2 | There are N people in Chefland where the age of the i th person in A [i].Given that a person needs to be at least X years old to vote, find the number of eligible voters. 3 | 4 | 5 | 6 | 7 | import java.util.*; 8 | import java.lang.*; 9 | import java.io.*; 10 | 11 | class Codechef 12 | { 13 | public static void main (String[] args) throws java.lang.Exception 14 | { 15 | // your code goes here 16 | Scanner sc=new Scanner(System.in); 17 | int n=sc.nextInt(); 18 | while(n-->0){ 19 | int c=0; 20 | int a=sc.nextInt(); 21 | int s=sc.nextInt(); 22 | int[] b=new int[a]; 23 | for(int i=0;i=s){ 26 | c++; 27 | } 28 | } 29 | System.out.println(c); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /day 40: -------------------------------------------------------------------------------- 1 | Chessboard Distance 2 | 3 | The Chessboard Distance for any two points (X1, Y1) and (X2, Y2) on a Cartesian 4 | plane is defined as max(| X1 - X2|, | Y1 - Y2|). 5 | 6 | You are given two points (X1, Y1) and (X2, Y2). Output their Chessboard Distance. 7 | 8 | Note that, | P| denotes the absolute value of integer P. For example, | - 4| = 4 and 9 | |7|=7. 10 | 11 | 12 | 13 | import java.util.*; 14 | import java.lang.*; 15 | import java.io.*; 16 | 17 | class Codechef 18 | { 19 | public static void main (String[] args) throws java.lang.Exception 20 | { 21 | // your code goes here 22 | Scanner sc=new Scanner(System.in); 23 | int n=sc.nextInt(); 24 | while(n-->0){ 25 | int a=sc.nextInt(); 26 | int b=sc.nextInt(); 27 | int c=sc.nextInt(); 28 | int d=sc.nextInt(); 29 | int g=Math.abs(c-a); 30 | int e=Math.abs(d-b); 31 | System.out.println(Math.max(g,e)); 32 | 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /day 64: -------------------------------------------------------------------------------- 1 | Chef And Operators 2 | Chef has just started Programming, he is in first year of Engineering. Chef is reading about Relational Operators. 3 | Relational Operators are operators which check relationship between two values. Given two numerical values A and B you need to help chef in finding the relationship between them that is, 4 | First one is greater than second or, First one is less than second or, First and second one are equal. 5 | 6 | import java.util.*; 7 | import java.lang.*; 8 | import java.io.*; 9 | 10 | class Codechef 11 | { 12 | public static void main (String[] args) throws java.lang.Exception 13 | { 14 | // your code goes here 15 | Scanner sc=new Scanner(System.in); 16 | int n=sc.nextInt(); 17 | while(n-->0){ 18 | int a=sc.nextInt(); 19 | int b=sc.nextInt(); 20 | if(a>b){ 21 | System.out.println(">"); 22 | } 23 | else if(a0){ 23 | int e=0,o=0; 24 | int t=sc.nextInt(); 25 | int a=sc.nextInt(); 26 | int b=sc.nextInt(); 27 | for(int i=0;i0){ 29 | int a=sc.nextInt(); 30 | int b=sc.nextInt(); 31 | int c=sc.nextInt(); 32 | int d=(a*b)/2; 33 | if(d0){ 19 | int a=sc.nextInt(); 20 | int b=sc.nextInt(); 21 | if(a>b){ 22 | if((a-b)%4==0){ 23 | System.out.println((a-b)/4); 24 | } 25 | else{ 26 | System.out.println(((a-b)/4)+1); 27 | 28 | } 29 | } 30 | else{ 31 | System.out.println("0"); 32 | } 33 |         } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /day 67: -------------------------------------------------------------------------------- 1 | we will learn how to print days of week in words using if else ladder statement. We will take a number between 1 to 7 as input from user, where 1 corresponds to Monday, 2 corresponds to Tuesday and so on. We will use if else ladder statement to print name of day in words 2 | 3 | 1 - Sunday 2 - Monday 3 - Tuesday 4 - Wednesday 5 - Thursday 6 - Friday 7 - Saturday lesser than 1 or more than 7 - Invalid day 4 | 5 | 6 | 7 | import java.io.*; 8 | import java.util.*; 9 | import java.text.*; 10 | import java.math.*; 11 | import java.util.regex.*; 12 | 13 | public class Solution { 14 | 15 | public static void main(String[] args) { 16 | /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ 17 | String[] a={"Sunday", "Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; 18 | Scanner sc=new Scanner(System.in); 19 | int n=sc.nextInt(); 20 | if(n>=1 &&n<=7){ 21 | System.out.println(a[n-1]); 22 | } 23 | else{ 24 | System.out.println("Invalid day"); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /day 32: -------------------------------------------------------------------------------- 1 | Chef and Water Bottles 2 | 3 | Chef has N empty bottles where each bottle has a capacity of X litres. 4 | There is a water tank in Chefland having K litres of water. Chef wants to fill the empty 5 | bottles using the water in the tank. 6 | 7 | Assuming that Chef does not spill any water while filling the bottles, find out the 8 | maximum number of bottles Chef can fill completely. 9 | 10 | 11 | import java.util.*; 12 | import java.lang.*; 13 | import java.io.*; 14 | 15 | class Codechef 16 | { 17 | public static void main (String[] args) throws java.lang.Exception 18 | { 19 | // your code goes here 20 | Scanner sc=new Scanner(System.in); 21 | int n=sc.nextInt(); 22 | while(n-->0){ 23 | int a=sc.nextInt(); 24 | int x=sc.nextInt(); 25 | int k=sc.nextInt(); 26 | if(x>k){ 27 | System.out.println("0"); 28 | } 29 | else if((k/x)>a){ 30 | System.out.println(a); 31 | } 32 | else{ 33 | System.out.println(k/x); 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /day 36: -------------------------------------------------------------------------------- 1 | Find Closest Number to Zero 2 | Given an integer array nums of size n, return the number with the value closest to 0 in nums . If 3 | there are multiple answers, return the number with the largest value. 4 | Example 1: 5 | 6 | Input: nums = [-4,-2,1,4,8] 7 | Output: 1 8 | Explanation: 9 | The distance from -4 to 0 is |-4| = 4. 10 | The distance from -2 to 0 is |-2| = 2. 11 | The distance from 1 to 0 is |1| = 1. 12 | The distance from 4 to 0 is |4| = 4. 13 | The distance from 8 to 0 is |8| = 8. 14 | Thus, the closest number to 0 in the array is 1. 15 | 16 | Example 2: 17 | 18 | Input: nums = [2,-1,1] 19 | Output: 1 20 | Explanation: 1 and -1 are both the closest numbers to 0, so 1 being 21 | 22 | 23 | class Solution { 24 | public int findClosestNumber(int[] nums) { 25 | int d=nums[0]; 26 | int[] a=new int[nums.length]; 27 | for(int i=0;i d)) { 30 | d = nums[i]; 31 | } 32 | } 33 | return d; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /day 29: -------------------------------------------------------------------------------- 1 | Chess Ratings 2 | Alice has recently started playing Chess. Her current rating is X. She noticed that when she wins a game, her rating increases by 8 points. 3 | Can you help Alice in finding out the minimum number of games she needs to win in order to make her rating greater than or equal to Y? 4 | 5 | 6 | 7 | import java.util.*; 8 | import java.lang.*; 9 | import java.io.*; 10 | 11 | class Codechef 12 | { 13 | public static void main (String[] args) throws java.lang.Exception 14 | { 15 | // your code goes here 16 | Scanner sc=new Scanner(System.in); 17 | int n=sc.nextInt(); 18 | while(n-->0){ 19 | int x=sc.nextInt(); 20 | int y=sc.nextInt(); 21 | int z=y-x; 22 | if(x==y){ 23 | System.out.println("0"); 24 | } 25 | else if(z<=8){ 26 | System.out.println("1"); 27 | } 28 | else if(z%8==0){ 29 | System.out.println(z/8); 30 | } 31 | else{ 32 | System.out.println((z/8)+1); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /day 8: -------------------------------------------------------------------------------- 1 | Given a string, , and two indices, and , print a substring consisting of all characters in the inclusive range from to . You'll find the String class' substring method helpful in completing this challenge. 2 | Input Format 3 | The first line contains a single string denoting . 4 | The second line contains two space-separated integers denoting the respective values of and . 5 | Constraints 6 | String consists of English alphabetic letters (i.e., ) only. 7 | Output Format 8 | Print the substring in the inclusive range from to . 9 | Sample Input 10 | Helloworld 11 | 3 7 12 | Sample Output 13 | lowo 14 | Explanation 15 | In the diagram below, the substring is highlighted in green 16 | SOLUTION: 17 | import java.io.*; 18 | import java.util.*; 19 | import java.text.*; 20 | import java.math.*; 21 | import java.util.regex.*; 22 | 23 | public class Solution { 24 | 25 | public static void main(String[] args) { 26 | Scanner in = new Scanner(System.in); 27 | String S = in.next(); 28 | int a = in.nextInt(); 29 | int b = in.nextInt(); 30 | System.out.println(S.substring(a,b)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /day 45: -------------------------------------------------------------------------------- 1 | Weights 2 | 3 | Chef is playing with weights. He has an object weighing W units. He also has three 4 | weights each of X, Y, and Z units respectively. Help him determine whether he can 5 | measure the exact weight of the object with one or more of these weights. 6 | 7 | If it is possible to measure the weight of object with one or more of these weights, print 8 | YES, otherwise print NO. 9 | 10 | import java.util.*; 11 | import java.lang.*; 12 | import java.io.*; 13 | 14 | class Codechef 15 | { 16 | public static void main (String[] args) throws java.lang.Exception 17 | { 18 | // your code goes here 19 | Scanner sc=new Scanner(System.in); 20 | int n=sc.nextInt(); 21 | while(n-->0){ 22 | int a=sc.nextInt(); 23 | int x=sc.nextInt(); 24 | int y=sc.nextInt(); 25 | int z=sc.nextInt(); 26 | if((x==a || y==a || z==a)||(x+y==a || x+z==a || y+z==a|| x+y+z==a)){ 27 | System.out.println("YES"); 28 | } 29 | else{ 30 | System.out.println("NO"); 31 | } 32 | 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /day 23: -------------------------------------------------------------------------------- 1 | It's the sale season again and Chef bought items worth a total of X rupees. The sale season offer is as follows: 2 | if X≤100, no discount. 3 | if 1005000, discount is 6 | 500 rupees. 7 | Find the final amount Chef needs to pay for his shopping 8 | 9 | 10 | 11 | 12 | import java.util.*; 13 | import java.lang.*; 14 | import java.io.*; 15 | 16 | class Codechef 17 | { 18 | public static void main (String[] args) throws java.lang.Exception 19 | { 20 | // your code goes here 21 | Scanner sc=new Scanner(System.in); 22 | int n=sc.nextInt(); 23 | while(n>0){ 24 | int a=sc.nextInt(); 25 | if(a<=100){ 26 | System.out.println(a); 27 | } 28 | else if(1000){ 22 | c++; 23 | a/=10; 24 | } 25 | while(b>0){ 26 | c1++; 27 | b/=10; 28 | } 29 | c=5-c; 30 | c1=5-c1; 31 | for(int i=0;i0){ 23 | int a=sc.nextInt(); 24 | int x=sc.nextInt(); 25 | int y=sc.nextInt(); 26 | int z=sc.nextInt(); 27 | if((x+y+z)<=a){ 28 | System.out.println("0"); 29 | } 30 | else if((x+z)<=a ||(y+z)<=a) 31 | { 32 | System.out.println("1"); 33 | } 34 | else{ 35 | System.out.println("2"); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /day 50: -------------------------------------------------------------------------------- 1 | Airlines 2 | 3 | An airline operates X aircraft every day. Each aircraft can carry up to 100 passengers. 4 | One day, N passengers would like to travel to the same destination. What is the 5 | minimum number of new planes that the airline must buy to carry all N passengers? 6 | 7 | Input Format 8 | 9 | . The first line of input will contain a single integer T, denoting the number of test 10 | cases. 11 | 12 | . Each test case consists of a single line containing two space-separated integers X 13 | and N - the number of aircraft the airline owns and the number of passengers 14 | travelling, respectively. 15 | 16 | import java.util.*; 17 | import java.lang.*; 18 | import java.io.*; 19 | 20 | class Codechef 21 | { 22 | public static void main (String[] args) throws java.lang.Exception 23 | { 24 | // your code goes here 25 | Scanner sc=new Scanner(System.in); 26 | int n=sc.nextInt(); 27 | while(n-->0){ 28 | int x=sc.nextInt(); 29 | int y=sc.nextInt(); 30 | int t=x*100; 31 | if(t>y){ 32 | System.out.println("0"); 33 | } 34 | else{ 35 | System.out.println(((y-t)+99)/100); 36 | } 37 | } 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /day 75: -------------------------------------------------------------------------------- 1 | Single-use Attack 2 | Chef is playing a video game, and is now fighting the final boss. 3 | The boss has H health points. Each attack of Chef reduces the health of the boss by X. 4 | Chef also has a special attack that can be used at most once, and will decrease the health of the boss by Y.Chef wins when the health of the boss is ≤0. 5 | What is the minimum number of attacks needed by Chef to win? 6 | 7 | 8 | import java.util.*; 9 | import java.lang.*; 10 | import java.io.*; 11 | 12 | class Codechef 13 | { 14 | public static void main (String[] args) throws java.lang.Exception 15 | { 16 | // your code goes here 17 | Scanner sc=new Scanner(System.in); 18 | int n=sc.nextInt(); 19 | while(n-->0){ 20 | int h=sc.nextInt(); 21 | int x=sc.nextInt(); 22 | int y=sc.nextInt(); 23 | if(h0){ 70 | int a=sc.nextInt(); 71 | int b=sc.nextInt(); 72 | int c=sc.nextInt(); 73 | float avg=(a+b); 74 | if(avg>c*2){ 75 | System.out.println("YES"); 76 | } 77 | else{ 78 | System.out.println("NO"); 79 | } 80 | n--; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /day 34: -------------------------------------------------------------------------------- 1 | The Last Levels 2 | 3 | Chef is playing a videogame, and is getting close to the end. He decides to finish the 4 | rest of the game in a single session. 5 | 6 | There are X levels remaining in the game, and each level takes Chef Y minutes to 7 | complete. To protect against eye strain, Chef also decides that every time he completes 8 | 3 levels, he will take a Z minute break from playing. Note that there is no need to take 9 | this break if the game has been completed. 10 | 11 | How much time (in minutes) will it take Chef to complete the game? 12 | 13 | 14 | 15 | 16 | 17 | 18 | import java.util.*; 19 | import java.lang.*; 20 | import java.io.*; 21 | 22 | class Codechef 23 | { 24 | public static void main (String[] args) throws java.lang.Exception 25 | { 26 | // your code goes here 27 | Scanner sc=new Scanner(System.in); 28 | int n=sc.nextInt(); 29 | while(n-->0){ 30 | int x=sc.nextInt(); 31 | int y=sc.nextInt(); 32 | int z=sc.nextInt(); 33 | int m=x/3; 34 | if(x%3==0 && x>3){ 35 | System.out.println((x*y)+(z*(m-1))); 36 | } 37 | else if(x>3){ 38 | System.out.println((x*y)+(z*m)); 39 | } 40 | else{ 41 | System.out.println(x*y); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /day 62: -------------------------------------------------------------------------------- 1 | Endless Appetizers 2 | 3 | Life is a like a box of of mozzarella sticks. You never know what you're gonna get, but you can predict with 100 percent accuracy that it will be a mozzarella stick. 4 | Chef's colleague issued a challenge to Chef: "If you eat more than X mozzarella sticks, I'll give you 30 rupees for each extra one you eat". 5 | For example, if X=5 and Chef eats 8 sticks, he would receive 90 rupees because he ate 3 extra sticks. 6 | You know that the restaurant serves Y mozzarella sticks per plate. 7 | You also know that Chef received R rupees from his colleague as a result of the challenge. 8 | What's the maximum number of plates of mozzarella sticks that Chef could have ordered? 9 | 10 | import java.util.*; 11 | import java.lang.*; 12 | import java.io.*; 13 | 14 | class Codechef 15 | { 16 | public static void main (String[] args) throws java.lang.Exception 17 | { 18 | // your code goes here 19 | Scanner sc=new Scanner(System.in); 20 | int n=sc.nextInt(); 21 | while(n-->0){ 22 | int x=sc.nextInt(); 23 | int y=sc.nextInt(); 24 | int r=sc.nextInt(); 25 | int z=x+(r/30); 26 | if(z%y==0){ 27 | System.out.println(z/y); 28 | } 29 | else{ 30 | System.out.println((z/y)+1); 31 | } 32 | 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /day 33: -------------------------------------------------------------------------------- 1 | Complementary Strand in a DNA 2 | You are given the sequence of Nucleotides of one strand of DNA through a string S of 3 | length N. S contains the character A, T, C, and Gonly. 4 | 5 | Chef knows that: 6 | 7 | . A is complementary to T. 8 | · T is complementary to A. 9 | · C is complementary to G. 10 | · Gis complementary to C. 11 | 12 | Using the string S, determine the sequence of the complementary strand of the DNA. 13 | 14 | 15 | import java.util.*; 16 | import java.lang.*; 17 | import java.io.*; 18 | 19 | class Codechef 20 | { 21 | public static void main (String[] args) throws java.lang.Exception 22 | { 23 | // your code goes here 24 | Scanner sc=new Scanner(System.in); 25 | int n=sc.nextInt(); 26 | while(n-->0){ 27 | int t = sc.nextInt(); 28 | String s = sc.next(); 29 | for( int i=0 ;i0){ 21 | int a=sc.nextInt(); 22 | int b=sc.nextInt(); 23 | int x=sc.nextInt(); 24 | int y=sc.nextInt(); 25 | 26 | if(a<=b){ 27 | if(a==b){ 28 | System.out.println("Yes"); 29 | } 30 | else{ 31 | if(x>= Math.abs(a-b)){ 32 | System.out.println("Yes"); 33 | } 34 | else{ 35 | System.out.println("No"); 36 | } 37 | 38 | } 39 | }else{ 40 | if(y>= Math.abs(a-b)){ 41 | System.out.println("Yes"); 42 | }else{ 43 | System.out.println("No"); 44 | } 45 | } 46 | } 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /day 20: -------------------------------------------------------------------------------- 1 | kattapa, as you all know was one of the greatest warriors of his time. The kingdom of Maahishmati had never lost a battle under him (as army-chief), 2 | and the reason for that was their really powerful army, also called as Mahasena.Kattapa was known to be a very superstitious person. He believed that a soldier is "lucky" 0 3 | if the soldier is holding an even number of weapons, and "unlucky" otherwise. 4 | He considered the army as "READY FOR BATTLE" if the count of "lucky" soldiers is strictly greater than the count of "unlucky" soldiers, and "NOT READY" otherwise. 5 | Given the number of weapons each soldier is holding, your task is to determine whether the army formed by all these soldiers is "READY FOR BATTLE" or "NOT READY". 6 | 7 | 8 | 9 | 10 | 11 | 12 | import java.util.*; 13 | import java.lang.*; 14 | import java.io.*; 15 | 16 | class Codechef 17 | { 18 | public static void main (String[] args) throws java.lang.Exception 19 | { 20 | // your code goes here 21 | Scanner sc=new Scanner(System.in); 22 | int c=0; 23 | int c1=0; 24 | int n=sc.nextInt(); 25 | int[] a=new int[n]; 26 | for(int i=0;i(n/2)){ 35 | System.out.println("READY FOR BATTLE"); 36 | } 37 | else{ 38 | System.out.println("NOT READY"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /day 22: -------------------------------------------------------------------------------- 1 | Let Me Eat Cake! Alice and Bob both bought a full cake each. Alice's cake has 𝐴 A slices, and Bob's cake has 𝐵 B slices. 2 | Alice will be unhappy if she has strictly less slices than Bob does. Similarly, Bob will be unhappy if he has strictly less slices than Alice does. 3 | Charlie doesn t want either of his friends to be unhappy, so he proposes a solution 4 | while either Alice or Bob are unhappy, he will attempt to restore happiness by eating half the remaining slices (rounded up) of whoever has more of them. For example, 5 | If 𝐴 = 8 A=8 and 𝐵 = 5 B=5, 6 | Charlie will eat half of Alice's slices, which is 8 2 = 4 2 8 ​ =4 slices. If 𝐴 = 2 A=2 and 𝐵 = 5 B=5, Charlie will eat half of Bob's slices, which is 5 2 2 5 ​ 7 | slices - rounded up, this is 3 3 slices. How many slices of cake will Charlie eat in total? 8 | 9 | 10 | 11 | import java.util.*; 12 | import java.lang.*; 13 | import java.io.*; 14 | 15 | class Codechef 16 | { 17 | public static void main (String[] args) throws java.lang.Exception 18 | { 19 | // your code goes here 20 | Scanner sc=new Scanner(System.in); 21 | int n=sc.nextInt(); 22 | while (n > 0) { 23 | int a = sc.nextInt(); 24 | int b = sc.nextInt(); 25 | int c = 0; 26 | while(a!=b){ 27 | if(a>b){ 28 | int slice=(a+1)/2; 29 | c+=slice; 30 | a-=slice; 31 | } 32 | else if(b>a){ 33 | int slice =(b+1)/2; 34 | c+=slice; 35 | b-=slice; 36 | } 37 | } 38 | 39 | System.out.println(c); 40 | n--; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /day 66: -------------------------------------------------------------------------------- 1 | Write a program to find given a specic date ,check whether the date is valid or not. Year will be in range 1900 to 9999 2 | 3 | Input Format 4 | 5 | INT INT INT Accept three integer as a input 6 | 7 | Constraints 8 | 9 | NULL 10 | 11 | Output Format 12 | 13 | Print the date is valid or not 14 | 15 | Sample Input 0 16 | 17 | 08/16/2000 18 | Sample Output 0 19 | 20 | Invalid 21 | import java.io.*; 22 | import java.util.*; 23 | import java.text.*; 24 | import java.math.*; 25 | import java.util.regex.*; 26 | 27 | public class Solution { 28 | 29 | public static void main(String[] args) { 30 | Scanner sc=new Scanner(System.in); 31 | String s=sc.nextLine(); 32 | String[] da=s.split("/"); 33 | int d=Integer.parseInt(da[0]); 34 | int m=Integer.parseInt(da[1]); 35 | int y=Integer.parseInt(da[2]); 36 | if(y>=1900 && y<=9999 && m>=1 &&m<=12){ 37 | 38 | if(d>=1&&d<=31&&(m==1||m==3||m==5||m==7|m==8||m==10||m==12)){ 39 | System.out.println("Valid"); 40 | } 41 | else if(d>=1&&d<=30&& (m==4||m==6||m==9||m==11)) { 42 | System.out.println("Valid"); 43 | } 44 | else if(d>=1&&d<=28&&m==2){ 45 | System.out.println("Valid"); 46 | } 47 | else if(d==29&&m==2&& ((y%4==0 && y%100!=0)|| y%400==0)){ 48 | System.out.println("Valid"); 49 | 50 | } 51 | else{ 52 | System.out.println("Invalid"); 53 | } 54 | } 55 | else{ 56 | System.out.println("Invalid"); 57 | } 58 | } 59 | } 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /day 43: -------------------------------------------------------------------------------- 1 | It is My Serve 2 | 3 | Alice and Bob are playing a game of table tennis where irrespective of the point scored, 4 | every player makes 2 consecutive serves before the service changes. Alice makes the 5 | first serve of the match. Therefore the first 2 serves will be made by Alice, then the next 6 | 2 serves will be made by Bob and so on. 7 | 8 | Let's consider the following example match for more clarity: 9 | 10 | . Alice makes the 1st serve. 11 | . Let us assume, Bob wins this point. (Score is 0 for Alice and 1 for Bob) 12 | . Alice makes the 2nd serve. 13 | . Let us assume, Alice wins this point. (Score is 1 for Alice and 1 for Bob) 14 | . Bob makes the 3Td serve. 15 | . Let us assume, Alice wins this point. (Score is 2 for Alice and 1 for Bob) 16 | . Bob makes the 4th serve. 17 | 18 | . Let us assume, Alice wins this point. (Score is 3 for Alice and 1 for Bob) 19 | . Alice makes the 5th serve. 20 | 21 | . And the game continues ... 22 | 23 | After the score reaches P and Q for Alice and Bob respectively, both the players forgot 24 | whose serve it is. Help them determine whose service it is. 25 | 26 | 27 | import java.util.*; 28 | import java.lang.*; 29 | import java.io.*; 30 | 31 | class Codechef 32 | { 33 | public static void main (String[] args) throws java.lang.Exception 34 | { 35 | // your code goes here 36 | Scanner sc=new Scanner(System.in); 37 | int n=sc.nextInt(); 38 | while(n-->0){ 39 | int x=sc.nextInt(); 40 | int y=sc.nextInt(); 41 | int z=(x+y)/2; 42 | if(z%2==0){ 43 | System.out.println("Alice"); 44 | } 45 | else{ 46 | System.out.println("Bob"); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /day 24: -------------------------------------------------------------------------------- 1 | Problems in your to-do list 2 | CodeChef recently revamped its practice page to make it easier for users to identify the next problems they should solve by introducing some new features: 3 | Recent Contest Problems - contains only problems from the last 2 contests 4 | Separate Un-Attempted, Attempted, and All tabs 5 | Problem Difficulty Rating - the Recommended dropdown menu has various difficulty ranges so that you can attempt the problems most suited to your experience 6 | Popular Topics and Tags 7 | Like most users, Chef didn’t know that he could add problems to a personal to-do list by clicking on the magic '+' symbol on the top-right of each problem page. But once he found out about it, he went crazy and added loads of problems to his to-do list without looking at their difficulty rating.Chef is a beginner and should ideally try and solve only problems with difficulty rating strictly less than 8 | 1000. Given a list of difficulty ratings for problems in the Chef’s to-do list, please help him identify how many of those problems Chef should remove from his to-do list, so that he is only left with problems of difficulty rating less than1000. 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | import java.util.*; 17 | import java.lang.*; 18 | import java.io.*; 19 | 20 | class Codechef 21 | { 22 | public static void main (String[] args) throws java.lang.Exception 23 | { 24 | // your code goes here 25 | Scanner sc=new Scanner(System.in); 26 | int n=sc.nextInt(); 27 | while(n-->0){ 28 | int c=0; 29 | int a=sc.nextInt(); 30 | int[] b=new int[a]; 31 | for(int i=0;i=1000){ 34 | c++; 35 | } 36 | 37 | } 38 | System.out.println(c); 39 | } 40 | } 41 | } 42 | --------------------------------------------------------------------------------