<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Gourav Kadu</title>
    <description>The latest articles on Forem by Gourav Kadu (@gouravmpk).</description>
    <link>https://forem.com/gouravmpk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F723369%2F75fe4287-b84a-4237-b99f-649231fc08a0.jpg</url>
      <title>Forem: Gourav Kadu</title>
      <link>https://forem.com/gouravmpk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/gouravmpk"/>
    <language>en</language>
    <item>
      <title>Where to practice your problem solving Skills?</title>
      <dc:creator>Gourav Kadu</dc:creator>
      <pubDate>Sat, 25 Mar 2023 18:12:40 +0000</pubDate>
      <link>https://forem.com/gouravmpk/where-to-practice-your-problem-solving-skills-4ch5</link>
      <guid>https://forem.com/gouravmpk/where-to-practice-your-problem-solving-skills-4ch5</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem solving skills are essential for anyone interested in pursuing a career in software engineering or computer science. Practicing these skills is crucial to becoming proficient in coding and programming. In this blog, we will discuss where you can practice your problem solving skills, with a focus on CodeChef, LeetCode, and other platforms.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;CodeChef&lt;/em&gt;&lt;/strong&gt;: CodeChef is a popular platform that hosts online programming competitions. It offers a wide range of programming problems, from beginner to advanced level. CodeChef conducts monthly contests, which are open to everyone, and you can participate in them to test your skills against other coders.&lt;br&gt;
Apart from contests, CodeChef also offers a practice section that contains a large number of problems for you to solve. The practice problems are divided into different categories such as beginner, easy, medium, and hard. This helps you to choose the right level of difficulty and work your way up.&lt;br&gt;
&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://www.codechef.com/" rel="noopener noreferrer"&gt;
      codechef.com
    &lt;/a&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;LeetCode&lt;/em&gt;&lt;/strong&gt;: LeetCode is another popular platform for practicing problem solving skills. It offers a comprehensive set of coding problems covering various topics such as data structures, algorithms, and database systems. The problems on LeetCode are divided into easy, medium, and hard categories, making it easier for you to choose the right level of difficulty.&lt;br&gt;
LeetCode also offers a feature called "mock interview," which allows you to practice coding interviews in a simulated environment. This is a great way to prepare for technical interviews and to get familiar with the types of questions you may encounter.&lt;br&gt;
&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://leetcode.com/" rel="noopener noreferrer"&gt;
      leetcode.com
    &lt;/a&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;HackerRank&lt;/em&gt;&lt;/strong&gt;: HackerRank is a platform that offers a wide range of coding challenges and problems. It covers various topics such as data structures, algorithms, and artificial intelligence. HackerRank also offers a leaderboard system that allows you to compete against other coders and track your progress. &lt;br&gt;
Apart from coding challenges, HackerRank also offers a section called "Interview Preparation Kit," which contains a curated set of problems that are commonly asked in technical interviews.&lt;br&gt;
&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://www.hackerrank.com/dashboard" rel="noopener noreferrer"&gt;
      hackerrank.com
    &lt;/a&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;ProjectEuler&lt;/em&gt;&lt;/strong&gt;: Project Euler is a platform that offers a series of mathematical and computational problems that require creative thinking and problem solving skills. The problems on Project Euler are not based on any particular programming language or platform, and you can solve them using any programming language of your choice.&lt;br&gt;
Project Euler offers a leaderboard system that allows you to track your progress and compete against other users. It also offers a forum where you can discuss the problems with other users and get help if you're stuck.&lt;br&gt;
&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://projecteuler.net/archives" rel="noopener noreferrer"&gt;
      projecteuler.net
    &lt;/a&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;In conclusion, practicing problem solving skills is essential for anyone interested in pursuing a career in software engineering or computer science. Platforms such as CodeChef, LeetCode, HackerRank, and Project Euler offer a wide range of problems and challenges that you can use to hone your skills. These platforms also offer various features such as mock interviews and leaderboard systems that allow you to track your progress and compete against other coders. So, start practicing today and take your problem solving skills to the next level!&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>programming</category>
      <category>java</category>
    </item>
    <item>
      <title>Structure Of .Net API</title>
      <dc:creator>Gourav Kadu</dc:creator>
      <pubDate>Wed, 15 Mar 2023 17:52:07 +0000</pubDate>
      <link>https://forem.com/gouravmpk/structure-of-net-api-27fh</link>
      <guid>https://forem.com/gouravmpk/structure-of-net-api-27fh</guid>
      <description>&lt;p&gt;Hey this blog will give you overall understanding/and feel of the working of API from Controller -&amp;gt; Services -&amp;gt; Database, if you don't know what Controller or Services don't worry just refer below image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe4ogm0ogzzvcqqx1i9wd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe4ogm0ogzzvcqqx1i9wd.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Client send request through &lt;strong&gt;UI(User Interface) then the request is sent to controller redirected to services to perform operation and retrieve/store data in Database and vice versa .&lt;/strong&gt; This may get you a rough idea of how it works.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Controllers are in API layer.&lt;/li&gt;
&lt;li&gt;Services are in Business layer.&lt;/li&gt;
&lt;li&gt;Data is in Database Layer.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  API Layer
&lt;/h2&gt;

&lt;p&gt;The API layer is responsible for handling incoming HTTP requests and returning responses. In an ASP.NET Core API, Controllers are implemented as classes that derive from the ControllerBase class. Each controller is responsible for handling requests for a specific set of endpoints.&lt;/p&gt;

&lt;p&gt;The API layer typically includes the following components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Endpoints: Endpoints are the URLs that the API exposes. Each endpoint corresponds to a method on the controller class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Actions: Actions are the methods on the controller class that handle incoming requests. They are responsible for processing the input, invoking the appropriate service methods, and returning the response.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Routing: Routing is the process of mapping incoming requests to the appropriate controller and action. It is typically configured using attributes on the controller and action methods.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Business Layer
&lt;/h2&gt;

&lt;p&gt;The services layer is responsible for encapsulating the business logic of the application. Services are typically implemented as singleton classes that are registered with the Dependency Injection (DI) container. The DI container is responsible for creating and managing the instances of the services.&lt;/p&gt;

&lt;p&gt;The services layer typically includes the following components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Interfaces: Interfaces define the contracts for the services. They specify the methods that the service provides and the inputs and outputs of those methods.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Implementations: Implementations are the concrete classes that implement the interfaces. They contain the actual implementation of the service methods.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Dependency Injection: The DI container is responsible for managing the dependencies between the services and other components of the application. It is used to inject the required services into the controllers and other components that require them.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Database Layer
&lt;/h2&gt;

&lt;p&gt;The database layer is responsible for handling the interactions between the application and the database. In an ASP.NET Core API, this layer is typically implemented using an Object-Relational Mapping (ORM) tool such as Entity Framework Core. The ORM provides an abstraction layer over the database, allowing developers to interact with the database using code instead of SQL queries.&lt;/p&gt;

&lt;p&gt;The database layer typically includes the following components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Entities: Entities are classes that represent the tables in the database. Each entity corresponds to a table, and the properties of the entity correspond to the columns in the table.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Here is how a Entity is written "User"&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;namespace YourNamespace.Models
{
    public class User
    {
        [Key]
        public int UserId { get; set; }

        [Required]
        [MaxLength(50)]
        public string FirstName { get; set; }

        [Required]
        [MaxLength(50)]
        public string LastName { get; set; }

        [Required]
        [MaxLength(100)]
        public string Email { get; set; }

        [Required]
        [MaxLength(50)]
        public string Password { get; set; }

        // Other properties and navigation properties can be added here
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;ul&gt;
&lt;li&gt;DbContext: The DbContext is a class that represents the database as a whole. It provides a way to query and manipulate the entities in the database.
Install "Microsoft.EntityFrameworkCore" from Nuget package manager.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Microsoft.EntityFrameworkCore;

namespace YourNamespace.Data
{
    public class YourDbContext : DbContext
    {
        public YourDbContext(DbContextOptions&amp;lt;YourDbContext&amp;gt; options) : base(options)
        {
        }

        public DbSet&amp;lt;User&amp;gt; Users { get; set; }

        // Other DbSets can be added here for other entities

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            // Configure entity mappings here
        }
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;ul&gt;
&lt;li&gt;Migrations: Migrations are scripts that update the database schema. They are used to create new tables, add or remove columns, and make other changes to the database.
Before running migration command add nuget package.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Microsoft.EntityFrameworkCore.Design&lt;br&gt;
Microsoft.EntityFrameworkCore.Tools&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Once you install these packages run &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Add-Migration &lt;br&gt;
Update-Database&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;This is just an Rough Explanation to make you feel the flow of the WebAPI project.&lt;br&gt;
Stick around for more detailed explanations and Codes.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Building an API with .NET</title>
      <dc:creator>Gourav Kadu</dc:creator>
      <pubDate>Tue, 24 Jan 2023 20:16:27 +0000</pubDate>
      <link>https://forem.com/gouravmpk/building-an-api-with-net-3kli</link>
      <guid>https://forem.com/gouravmpk/building-an-api-with-net-3kli</guid>
      <description>&lt;p&gt;Building an API with .NET is a straightforward process that can be accomplished with a few simple steps. In this blog, we will go over how to create a basic .NET API using ASP.NET Core, which is the most popular and recommended framework for building web APIs on .NET.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Step 1: Install the .NET SDK&lt;br&gt;
To get started, you will need to have the .NET SDK (Software Development Kit) installed on your machine. You can download the SDK from the official .NET website. Once the SDK is installed, you should have access to the dotnet command-line tool, which you can use to create, build, and run .NET applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Step 2: Create a new API project&lt;br&gt;
To create a new API project, open the command prompt and navigate to the directory where you want to create your project. Then run the following command:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet new webapi -n MyApi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will create a new API project called "MyApi" using the webapi template. The template will create the basic structure of an API, including a startup file, a controller, and a launchSettings.json file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 3: Add a new controller
A controller is responsible for handling incoming HTTP requests and returning the appropriate response. To add a new controller, create a new file in the Controllers folder called "ValuesController.cs" and add the following code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ApiController]
[Route("[controller]")]
public class ValuesController : ControllerBase
{
    // GET api/values
    [HttpGet]
    public ActionResult&amp;lt;IEnumerable&amp;lt;string&amp;gt;&amp;gt; Get()
    {
        return new string[] { "value1", "value2" };
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code defines a new controller called "ValuesController" that handles GET requests to the "api/values" endpoint. The controller returns an array of strings as the response.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 4: Build and run the API
To build and run the API, navigate to the project directory in the command prompt and run the following command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will build and run the API, and you should see the message "Now listening on: &lt;a href="http://localhost:5000" rel="noopener noreferrer"&gt;http://localhost:5000&lt;/a&gt;" in the command prompt.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 5: Test the API
To test the API, open a web browser and navigate to "&lt;a href="http://localhost:5000/api/values" rel="noopener noreferrer"&gt;http://localhost:5000/api/values&lt;/a&gt;". You should see the array of strings returned by the controller.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Congratulations, you have now created a basic .NET API! Of course, this is just the beginning, and you can add more functionality and features to your API as needed. Some popular libraries and frameworks that you can use to extend your API include:&lt;/p&gt;

&lt;p&gt;Entity Framework Core for database access&lt;br&gt;
AutoMapper for mapping between models and entities&lt;br&gt;
Swagger for generating API documentation&lt;br&gt;
MediatR for handling CQRS pattern&lt;br&gt;
This is just a basic example to help you get started with .NET API development. With .NET's rich set of tools and libraries, the possibilities for building robust and scalable APIs are endless.&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
    <item>
      <title>Interface In JAVA &amp; Multiple Inheritance</title>
      <dc:creator>Gourav Kadu</dc:creator>
      <pubDate>Sun, 12 Dec 2021 17:13:24 +0000</pubDate>
      <link>https://forem.com/gouravmpk/interface-in-java-multiple-inheritance-1f5f</link>
      <guid>https://forem.com/gouravmpk/interface-in-java-multiple-inheritance-1f5f</guid>
      <description>&lt;h2&gt;
  
  
  MULTIPLE INHERITANCE
&lt;/h2&gt;

&lt;p&gt;*&lt;em&gt;Lets Understand what multiple inheritance is *&lt;/em&gt;&lt;br&gt; &lt;em&gt;Multiple inheritance is a feature of some object-oriented computer programming languages in which an object or class can inherit features from more than one parent object or parent class.&lt;/em&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V4jCQMKa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1639325732806/u5VziWUu2.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V4jCQMKa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1639325732806/u5VziWUu2.jpeg" alt="Inheritance-sm.jpg" width="500" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;as shown in  above figure in multiple inheritance child class can have 2 or more base class to achieve this we need INTERFACE.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  INTERFACE
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;An interface in Java is a blueprint of a class. It has static constants and abstract methods.&lt;/em&gt;&lt;br&gt;
i.e. An Interface can only contain abstract methods() and variables, it cannot have body of a method.&lt;br&gt;
It cannot be instantiated just like the abstract class.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;So where do we declare the body of these methods??&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The body of method is declared inside a class where the method is needed according to the programmer's requirement.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How to declare and interface?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Interface is declared using &lt;em&gt;interface&lt;/em&gt; keyword &lt;br&gt; &lt;strong&gt;Syntax :&lt;/strong&gt;&lt;br&gt; interface interface_name{ abstract methods}&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Note &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To use declared interface in class we need to use &lt;em&gt;implements&lt;/em&gt; keyword&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Implementation
&lt;/h3&gt;

&lt;p&gt;First we will create a interface "print" and inside it we will create a abstract method print();&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface printgib{
void print();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we got our interface ready to be used by classes so lets create classes abc and gk and implement interface  in it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
public class abc implements printgib{
public void print(){                     //1st implementation of print 
System.out.println("I love you 3000"); 
}
public static void main(String[] args){
abc obj = new abc();
gk obj1 = new gk();
obj.print();
obj1.print();
}
}

class gk implements printgib{
public void print(){                   //2nd implementation of print 
System.out.println("I am Gk");
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;as shown in above code we achieved multiple inheritance and implemented interface.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now to run the code save the file and
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;javac file_name.java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java abc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Output:-
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GaQlnxgw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1639330486384/FuAwp58rW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GaQlnxgw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1639330486384/FuAwp58rW.png" alt="image.png" width="555" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>oop</category>
      <category>programming</category>
    </item>
    <item>
      <title>TCS Digital QUESTION</title>
      <dc:creator>Gourav Kadu</dc:creator>
      <pubDate>Sat, 13 Nov 2021 10:28:48 +0000</pubDate>
      <link>https://forem.com/gouravmpk/tcs-digital-question-20dp</link>
      <guid>https://forem.com/gouravmpk/tcs-digital-question-20dp</guid>
      <description>&lt;h1&gt;
  
  
  Question 2 Statement
&lt;/h1&gt;

&lt;p&gt;A store has different categories of products in stock as shown below. &lt;br&gt;
Item Number=[101, 102, 103, 108] &lt;br&gt;
Item Name=[Milk, Cheese , Ghee, Bread]&lt;br&gt;
Price=[42, 50, 500, 40]&lt;br&gt;
Stock =[10, 20, 15, 16]&lt;/p&gt;

&lt;p&gt;When user give input with 2 values as &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Item number for item which user wish to buy&lt;/li&gt;
&lt;li&gt;Quantity for the item entered above&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When user enters above input, the code should check the stock&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If quantity is less than stock and item is available display a notification message showing
Output Line1 [prices] INR
Calculate total price in float with precision.
Output Line2 quantity LEFT
// updated stock for item after after purchase&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2.If the quantity and stocks less than quantity entered by the user while placing order, then display message&lt;br&gt;
Output Line1 NO STOCK&lt;br&gt;&lt;br&gt;
Output Line2 quantity LEFT&lt;br&gt;&lt;/p&gt;

&lt;p&gt;3.If user enter character as input for item number and quantity or enter item number which is not available then display following message and stop Output Line1- INVALID INPUT Make sure the string message displayed in output.&lt;/p&gt;
&lt;h3&gt;
  
  
  Sample INPUT :-
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;101
4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Sample OUTPUT:-
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;168.0 INR
6 LEFT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Sample INPUT :-
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;104
20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Sample OUTPUT:-
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NO STOCK
16 LEFT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;To Run the code or Tinker with code &lt;a href="https://www.jdoodle.com/a/41F2"&gt;Click here&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.*;
public class codechef {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[] item_number = {101,102,103,104};
        String[] item_name = {"Milk", "Cheese", "Ghee", "Bread"};
        int[] price = {42,50,500,40};
        int[] stock = {10,20,15,16};

    int item_num = sc.nextInt();
    int quant = sc.nextInt();
    int temp =0,flag=0;;
    for(int i = 0; i&amp;lt;4 ;i++) {
        if(item_num ==item_number[i]) {             
        temp = i;   
        flag=1;
        }
        }


    if(flag== 0){
    System.out.println("INVALID INPUT");
    System.exit(0);
    }
    if(quant &amp;gt; stock[temp]) {
        System.out.println("NO STOCK");
        System.out.println(stock[temp]+" "+"LEFT");
    }else if(quant &amp;lt;= stock[temp]){
    System.out.println((float)(price[temp]*quant)+" "+"INR");
    System.out.println(stock[temp]-quant+" "+"LEFT");
    }
    }
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>java</category>
      <category>tcs</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Zensar Technologies Assessment question Coding 1 &amp; 2</title>
      <dc:creator>Gourav Kadu</dc:creator>
      <pubDate>Thu, 11 Nov 2021 15:45:39 +0000</pubDate>
      <link>https://forem.com/gouravmpk/zensar-technologies-assessment-question-coding-1-2-1h8p</link>
      <guid>https://forem.com/gouravmpk/zensar-technologies-assessment-question-coding-1-2-1h8p</guid>
      <description>&lt;h1&gt;
  
  
  First
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Given an email address extract username U by eliminating the "@" and subsequent character to form a new string and add length of U at the end of the string to be formed .&lt;br&gt;
Read Sample input output for better understanding.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Input1:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gourav.mk@gmail.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Output1:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gourav.mk9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Input2:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hellofrankyji@gmail.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Output:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hellofrankyji13
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Solution:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Paste the sample input in STDIN to check the code &lt;/li&gt;
&lt;li&gt;To Tinker the code &lt;a href="https://www.jdoodle.com/a/40n1"&gt;click here&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.io.*;
import java.util.*;
public class TestClass {
    public static void Extraction(String Str){
        String sep = "@";
        int pos = Str.lastIndexOf(sep);
        String input = Str.substring(0,pos);
        int len = input.length();
        System.out.print(input+""+len);
    }

    public static void main(String args[]) {
   Scanner sc = new Scanner(System.in);
   String Str = sc.nextLine();
   Extraction(Str);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Second
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Given two integer A and B, write a program to print binary equivalent N of the GCD(greatest common divisor) of A and V and also print the number of 1s in N.&lt;br&gt;
Read the Sample input output to understand better.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Input1:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;20 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Output1:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10100
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explanation 1:
&lt;/h3&gt;

&lt;p&gt;*will be updated soon *&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Paste the sample input in STDIN to check the code &lt;/li&gt;
&lt;li&gt;To Tinker the code [click here].(&lt;a href="https://www.jdoodle.com/a/40oN"&gt;https://www.jdoodle.com/a/40oN&lt;/a&gt;)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.*;
public class TestClass {
    static int findgcd(int x, int y){
        int gcd = 1;
        for(int i = 1 ; i&amp;lt;=x &amp;amp;&amp;amp; x&amp;lt;=y ; i++){
            if(x%i == 0 &amp;amp;&amp;amp; y%i==0){
                gcd = i;
            }
        }
        return gcd;
    }
    public static String binaryString(int n){
        String b="";
        b = Integer.toBinaryString(n);

        return b;
    }
    public static int numberOfOnes(String b){
        int count =0;
        for(int i =0; i &amp;lt; b.length();i++){
            if(b.charAt(i)=='1'){
            count++;}
        }
        return count;
    }
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int x= sc.nextInt();
        int y= sc.nextInt();
    String b = binaryString(findgcd(x,y));
    System.out.println(b);
    System.out.print(numberOfOnes(b));

    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>java</category>
      <category>string</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Hello World In REACT NATIVE</title>
      <dc:creator>Gourav Kadu</dc:creator>
      <pubDate>Wed, 03 Nov 2021 05:56:04 +0000</pubDate>
      <link>https://forem.com/gouravmpk/hello-world-in-react-native-54jm</link>
      <guid>https://forem.com/gouravmpk/hello-world-in-react-native-54jm</guid>
      <description>&lt;h1&gt;
  
  
  Steps To Create App in React Native
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Setup environment for react native.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open Terminal/command prompt in the folder you want to create app in .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter&lt;br&gt;
&lt;br&gt;
&lt;code&gt;npx react-native init app_name&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635867230207%2FrH_ko5pmt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635867230207%2FrH_ko5pmt.png" alt="2021-11-02.png"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once the app is created , Open app folder in your ide or editor (I'm using VS code).&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635867402936%2FRTHPymHid.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635867402936%2FRTHPymHid.png" alt="2021-11-02 (3).png"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open App.js, there will be default code template given try running it by opening Terminal/command prompt in App Folder respectively.&lt;br&gt;&lt;br&gt;
To run the app write&lt;br&gt;
&lt;br&gt;
&lt;code&gt;npx react-native run-android&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635867683035%2FH68LafNAa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635867683035%2FH68LafNAa.png" alt="2021-11-02 (2).png"&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once the App runs replace all the code in App.js with&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, {Component} from 'react';  
import {Platform, StyleSheet, Text, View} from 'react-native';  


export default class App extends Component {  
  render() {  
    return (  
      &amp;lt;View&amp;gt;  
        &amp;lt;Text&amp;gt;Hello World&amp;lt;/Text&amp;gt;  
      &amp;lt;/View&amp;gt;  
    );  
  }  
}  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And refresh the code by pressing "R" in node terminal , don't forget to save before refreshing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635867902197%2F_SzuCWHzv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635867902197%2F_SzuCWHzv.png" alt="2021-11-02 (5).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  THATS IT FOR Hello World :)
&lt;/h2&gt;

&lt;p&gt;Try Tinkering with the code to understand better.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>react</category>
      <category>opensource</category>
      <category>android</category>
    </item>
    <item>
      <title>Implementation Of Stacks Using Array In JAVA</title>
      <dc:creator>Gourav Kadu</dc:creator>
      <pubDate>Tue, 02 Nov 2021 15:20:58 +0000</pubDate>
      <link>https://forem.com/gouravmpk/implementation-of-stacks-using-array-in-java-599h</link>
      <guid>https://forem.com/gouravmpk/implementation-of-stacks-using-array-in-java-599h</guid>
      <description>&lt;h1&gt;
  
  
  Statement
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;I created an Stack using array and created its Three Basic operations i.e. PUSH , POP and Top.&lt;br&gt;&lt;br&gt;
where PUSH is insertion operation.&lt;br&gt; POP is deletion operation. &lt;br&gt; Top just returns variable at top of stack. &lt;br&gt; I also added Logic of "Overflow" and "Underflow" state with some exception handling.&lt;br&gt;
The code is explained in details using comments .&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;To Tinker the inputs and check the operations&lt;/strong&gt;  &lt;a href="https://www.jdoodle.com/a/3XbY"&gt;Click Here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.*;

public class Template {
    static int max_size;
    static int top ;
    int temp;
    static int arr[];
public void Stack(int size) {
         arr = new int[size];
         max_size = arr.length;
         top = -1;
    }

    public boolean empty() {          //checking if stack is empty .
        return temp  == -1;
    }

    public boolean full() {  //checking if stack is full .
        return top + 1 == max_size;
    }

    public void push(int Ip) {//PUSH operation
        if(top &amp;lt;= max_size) {
        top++;
        }
        try {                           //bit of exception handling while insertion/PUSH operation
            if(top &amp;gt;max_size) {
                throw new ArrayIndexOutOfBoundsException();       
            }
            else if(empty()|| top&amp;lt;=max_size) {
            arr[top] = Ip; 
            }
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("Stack overflow");
            top--;
        }   
    }


    public void pop() {   // POP 
         temp = top;
    if(top &amp;gt; -1) {           // stop top from further decrementing if already -1,
        top--;              // if not it will interfere with push operation.
        }else { temp--;}        
    try {                       //bit of exception handling while deletion/POP operation
        if(temp &amp;lt; -1) throw new ArrayIndexOutOfBoundsException();
    }catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("Stack underflow");  

    }
    }

    public void Top()
    {
         System.out.println(arr[top] +" at index "+ top);
    }


    public static void main(String[] args)
    {

        Template t = new Template();
        t.Stack(4);
        t.push(6);
        t.Top(); // &amp;lt;---- Return Top variable of Stack
        t.pop(); // &amp;lt;--- 6 is removed from the stack so stack will be empty
        t.pop(); // &amp;lt;-- so removing element from empty stack will return "UNDERFLOW"
        t.push(101);
        t.Top(); // &amp;lt;---- Return Top variable of Stack
        t.push(10);
        t.Top(); // &amp;lt;---- Return Top variable of Stack
        t.push(112);   
        t.Top();    // &amp;lt;---- Return Top variable of Stack
        t.push(14); //&amp;lt;----- stack will be full at this point
        t.Top();
        t.push(146); // so if you push anything it will print "OVERFLOW"
        t.push(110);
        t.Top(); // &amp;lt;---- Return Top variable of Stack
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>java</category>
      <category>database</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Fibonacci Number Using Recursion</title>
      <dc:creator>Gourav Kadu</dc:creator>
      <pubDate>Sun, 17 Oct 2021 21:22:59 +0000</pubDate>
      <link>https://forem.com/gouravmpk/fibonacci-number-using-recursion-42b9</link>
      <guid>https://forem.com/gouravmpk/fibonacci-number-using-recursion-42b9</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;In Below code we have used recursion to return Fibonacci number and Fibonacci series.&lt;br&gt;
To run the code &lt;a href="https://gouravmk.hashnode.dev/fibonacci-number-using-recursion"&gt;click here.&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Input :-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output :-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;55
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Code in C++ :-
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;

using namespace std;
int f(int n){
if(n ==0) return 0;
else if(n ==1 || n == 2) return 1;
else return f(n-2)+ f(n-1);
}
int main() {
  int n;
  cin&amp;gt;&amp;gt;n;
  cout&amp;lt;&amp;lt;n&amp;lt;&amp;lt;"th fibonacci number is "&amp;lt;&amp;lt;f(n)&amp;lt;&amp;lt;"\n";
  /*cout&amp;lt;&amp;lt;"Fibonacci Series till " &amp;lt;&amp;lt; n &amp;lt;&amp;lt;"\n";
  for(int i =0 ; i &amp;lt; n ; i++){
      cout&amp;lt;&amp;lt;" "&amp;lt;&amp;lt;f(i);
  }*/
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Code in Java :-
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.*;
public class MyClass {
    public static int f(int n) {
     if(n == 0) return 0;
     else if(n == 1 || n ==2) return 1;
     else return f(n-2) + f(n-1);   
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(n+"th Febonacci number is :- " + f(n));
    /*  for(int i=0; i&amp;lt; n ; i++){    //uncomment to print series
            System.out.println(" "+f(i));
        } */
        System.out.println("\n Time complexity O(2^n)");
        sc.close();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Input :-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;15
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output :-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;610
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>cpp</category>
      <category>java</category>
      <category>algorithms</category>
      <category>recursion</category>
    </item>
    <item>
      <title>Yet Another Number Game</title>
      <dc:creator>Gourav Kadu</dc:creator>
      <pubDate>Fri, 15 Oct 2021 07:16:08 +0000</pubDate>
      <link>https://forem.com/gouravmpk/yet-another-number-game-4pdd</link>
      <guid>https://forem.com/gouravmpk/yet-another-number-game-4pdd</guid>
      <description>&lt;h2&gt;
  
  
  Statment
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Alice and Bob play the following game. They choose a number N to play with. The rules are as follows :&lt;br&gt;
1) Alice plays first, and the two players alternate.&lt;br&gt;
2) In his/her turn, a player can subtract from N any proper divisor (not equal to N) of N. The number thus obtained is the new N.&lt;br&gt;
3) The person who cannot make a move in his/her turn loses the game.&lt;br&gt;
Assuming both play optimally, who wins the game ?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Input :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first line contains the number of test cases T. Each of the next T lines contains an integer N.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Output T lines, one for each test case, containing "ALICE" if Alice wins the game, or "BOB" otherwise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample Input :&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2
1
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sample Output :&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BOB
ALICE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Constraints :&lt;/strong&gt;&lt;br&gt;
1 &amp;lt;= T &amp;lt;= 10000&lt;br&gt;
1 &amp;lt;= N &amp;lt;= 1000000000&lt;/p&gt;

&lt;p&gt;Note : For the first test case, Alice cannot make any move and hence Bob wins the game. For the second test case, Alice subtracts 1 from N. Now, Bob cannot make a move and loses the game.&lt;/p&gt;
&lt;h3&gt;
  
  
  Solution:-
&lt;/h3&gt;

&lt;p&gt;To run the code&lt;a href="https://gouravmk.hashnode.dev/yet-another-number-game"&gt; click here.&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.*;
public class MyClass {
    public static void main(String args[]) {
     Scanner sc = new Scanner(System.in);  

        int T = sc.nextInt();  
        int arr[] = new int[T];
        int count=0;
        for(int i = 0; i &amp;lt;T; i++) {
            arr[i]= sc.nextInt();
        }
        for(int i = 0; i &amp;lt;T; i++) {
            if(arr[i]==1) {
                System.out.println("BOB");
            }else if(arr[i]%2==1) {
                System.out.println("BOB");
            }else {
                System.out.println("ALICE");
            }
        }
        sc.close();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>codenewbie</category>
      <category>java</category>
      <category>easy</category>
      <category>programming</category>
    </item>
    <item>
      <title>TechMahindra "Student Report"Coding Question</title>
      <dc:creator>Gourav Kadu</dc:creator>
      <pubDate>Thu, 14 Oct 2021 06:24:09 +0000</pubDate>
      <link>https://forem.com/gouravmpk/student-report-coding-question-1e1</link>
      <guid>https://forem.com/gouravmpk/student-report-coding-question-1e1</guid>
      <description>&lt;h2&gt;
  
  
  Statement :-
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Given a list of N students, every student is marked for M subjects. Each student is denoted by an index value. Their teacher Ms. Margaret must ignore the marks of any 1 subject for every student. For this she decides to ignore the subject which has the lowest class average.&lt;br&gt;Your task is to help her find that subject, calculate the total marks of each student in all the other subjects and then finally return the array of the total marks scored by each student.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Input Specification:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;input1:&lt;/strong&gt;&lt;br&gt;
 An integer value N denoting number of students&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;input2:&lt;/strong&gt;&lt;br&gt;
An integer value M denoting number of subjects &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;input3:&lt;/strong&gt;&lt;br&gt;
A 2-D integer array of size N'M containing the marks of all students in each subject.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output Specification:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Return an integer array of size N containing the total marks of each student afte deducting the score for that one subject.&lt;/p&gt;
&lt;h3&gt;
  
  
  Example 1:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;INPUT&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3 5
75 76 65 87 87
78 76 68 56 89
67 87 78 77 65
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;OUTPUT&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;325 299 296
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example 2:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;INPUT&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3 3
50 30 70 
30 70 99 
99 20 30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;OUTPUT&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;120 129 129
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Out of these subjects, the students average was lowest in subject 2 &lt;br&gt; i.e 30+70+20= 120/3=40&lt;/p&gt;

&lt;p&gt;So the teacher will ignore marks of this subject and will consider the title other two subjects for each of the three students i.e. 120 129 129 respectively&lt;/p&gt;

&lt;p&gt;Hence (120 129 129) is returned as the final output.&lt;/p&gt;

&lt;p&gt;Solution:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.*;
public class MyClass {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);  

        int row = sc.nextInt();   
        int col = sc.nextInt();
        int avg[]= new int[row];
        int ans[] = new int[row];
        int arr[][]= new int[row][col];
        int res[]= new int[row];
        for(int i = 0; i &amp;lt;row; i++) {
            for(int j=0;j&amp;lt;col;j++) {
                arr[i][j]= sc.nextInt();
            }
        }

        /*//verifying i/p
        for(int i = 0; i &amp;lt;row; i++) {
            for(int j=0;j&amp;lt;col;j++) {
                System.out.print(arr[i][j]+" ");
            }
            System.out.println("");
        }*/

        for(int i = 0; i &amp;lt;row; i++) { //calculating and storing average of each column
            for(int j=0;j&amp;lt;row;j++) {
            ans[i] += arr[j][i];

            }
        avg[i] = ans[i]/row; 

        }

    int min = avg[0];
        int eleminate_Index =0;
        for(int i = 1; i &amp;lt; row; i++) { // minimum average calculated and ..
            if(avg[i]&amp;lt;min) {
                min = avg[i];
                eleminate_Index = i; //..index of it stored.
            }
        }

        /*
        System.out.println(min);
        System.out.println(p);
        */
        for(int i = 0 ; i&amp;lt;row; i++) {
            for(int j=0; j&amp;lt;col; j++){
                if(eleminate_Index!=j) {//calculating sum of remaining subjects
                    res[i]+=arr[i][j];
                }
        }

        }
        for(int j=0; j&amp;lt;row; j++){
            System.out.print(res[j]+" ");
            }



        sc.close();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>implementation</category>
      <category>java</category>
      <category>array</category>
      <category>codecity</category>
    </item>
    <item>
      <title>Ciel and A-B Problem</title>
      <dc:creator>Gourav Kadu</dc:creator>
      <pubDate>Wed, 13 Oct 2021 09:19:51 +0000</pubDate>
      <link>https://forem.com/gouravmpk/ciel-and-a-b-problem-ekn</link>
      <guid>https://forem.com/gouravmpk/ciel-and-a-b-problem-ekn</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;In Ciel's restaurant, a waiter is training. Since the waiter isn't good at arithmetic, sometimes he gives guests wrong change. Ciel gives him a simple problem. What is A-B (A minus B) ?&lt;br&gt;&lt;br&gt;
Surprisingly, his answer is wrong. To be more precise, his answer has exactly one wrong digit. Can you imagine this? Can you make the same mistake in this problem?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Input&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
An input contains 2 integers A and B.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Print a wrong answer of A-B. Your answer must be a positive integer containing the same number of digits as the correct answer, and exactly one digit must differ from the correct answer. Leading zeros are not allowed. If there are multiple answers satisfying the above conditions, anyone will do.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample input:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5858 1234
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sample output&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;4625
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output details:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The correct answer of 5858-1234 is 4624. So, for instance, 2624, 4324, 4623, 4604 and 4629 will be accepted, but 0624, 624, 5858, 4624 and 04624 will be rejected.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Solution:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.*;

class Codechef
{
    public static void main (String[] args) throws java.lang.Exception
    {
    Scanner sc= new Scanner(System.in);
    int n= sc.nextInt();
    int m = sc.nextInt();
    int res = 0;
    if(n&amp;gt;m) {
        res= n-m;
    }else if(m&amp;gt;n) {
        res=m-n;
    }else {
        res=0;
    }
    int rem = res%10;


        if(rem&amp;lt;9) {
            System.out.println(res+1);
        }
        else if(rem == 9) {
            System.out.print(res-1);
        }


    sc.close();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>math</category>
      <category>implementation</category>
      <category>easy</category>
      <category>java</category>
    </item>
  </channel>
</rss>
