이 블로그 검색

2023년 7월 30일 일요일

LeetCode 1512. Number of Good Pairs Java Solution

Problem

Number of Good Pairs - LeetCode

Problem Solving Approach

This is a problem that tests your ability to work with nested loops (for loop inside another for loop) and multiple conditions (if statements with the && operator).

Github Link

https://github.com/eunhanlee/LeetCode_1512_NumberofGoodPairs_Solution.git

Time Complexity: O(n^2), Space Complexity: O(k)

class Solution {
    /**
     * Calculates the number of identical pairs in the given array.
     *
     * @param nums An array of integers.
     * @return The number of identical pairs in the array.
     */
    public int numIdenticalPairs(int[] nums) {
        int counter = 0; // A variable to count the number of identical pairs.

        // Iterate through each element of the array.
        for (int i = 0; i < nums.length; i++) {
            // Compare the current element with the rest of the elements in the array.
            for (int j = 0; j < nums.length; j++) {
                // Check if the element at index j is equal to the element at index i
                // and ensure that j is greater than i to avoid duplicates.
                if (nums[j] == nums[i] && j > i) {
                    counter++; // Increment the counter if a good pair is found.
                }
            }
        }

        return counter; // Return the total number of identical pairs in the array.
    }
}

LeetCode 2235. Add Two Integers Java Solution

Problem

Add Two Integers - LeetCode

Problem Solving Approach

  • This problem tests the ability to perform simple arithmetic operations and return the result.
  • The parentheses () are not necessary to use, considering Java operator precedence.

Reference

Java Operator Precedence

Github Link

https://github.com/eunhanlee/LeetCode_2235_AddTwoIntegers_Solution.git

Time Complexity: O(1), Space Complexity: O(1)

class Solution {
    /**
     * Returns the sum of two integers.
     *
     * @param num1 The first integer.
     * @param num2 The second integer.
     * @return The sum of num1 and num2.
     */
    public int sum(int num1, int num2) {
        return num1 + num2;
    }
}

LeetCode 1431. Kids With the Greatest Number of Candies Java Solution

Problem

Kids With the Greatest Number of Candies - LeetCode

Approach

  • Algorithm
    • First, find the maximum value in the given array.
    • Traverse each element in the array, and for each kid, check if adding the extra candies makes their candy count greater than or equal to the maximum count.
    • If it is greater, add true to the result list, otherwise add false.
  • There is no need to put candy + extraCandies inside parentheses in the if statement (if(candy + extraCandies < max)). Java operator precedence will handle it correctly without the need for explicit grouping.
  • The if statement can be replaced with the ternary operator:
result.add(candy + extraCandies >= max ? true : false);

References

Java Operator Precedence

What is Java Ternary Operator(?:)

Github Link

https://github.com/eunhanlee/LeetCode_1431_KidsWiththeGreatestNumberofCandies_Solution.git

Time Complexity: O(n), Space Complexity: O(n)

/**
 * Determines whether each kid can have the maximum number of candies considering the extra candies.
 *
 * @param candies       An integer array representing the number of candies each kid has.
 * @param extraCandies  The number of extra candies each kid can have.
 * @return              A list of booleans representing whether each kid can have the maximum number of candies.
 */
public List<Boolean> kidsWithCandies(int[] candies, int extraCandies) {
    // Find the maximum number of candies in the given array.
    int max = 0;
    for (int candy : candies) {
        max = Math.max(max, candy);
    }

    // Check if each kid can have the maximum number of candies.
    List<Boolean> result = new ArrayList<>(candies.length);
    for (int candy : candies) {
        // If adding the extra candies makes the current kid's candy count greater than or equal to the maximum count,
        // consider them able to have the maximum number of candies.
        result.add(candy + extraCandies >= max ? true : false);
    }

    return result;
}

LeetCode 217. Contains Duplicate Java Solution

Problem

Problem Link

Time Complexity: O(n), Space Complexity: O(n)

class Solution {
    public boolean containsDuplicate(int[] nums) {
        // Create a HashMap to store the elements of the array.
        HashMap<Integer, Integer> map = new HashMap<>();

        // Traverse all elements in the array.
        for (int temp : nums) {
            // Check if the current element exists in the HashMap.
            if (map.containsKey(temp)) {
                // If it exists, it means there is a duplicate element in the array, so return true.
                return true;
            } else {
                // If it doesn't exist, add the current element to the HashMap.
                // The value '1' is used to indicate the existence of a duplicate element.
                map.put(temp, 1);
            }
        }
        // If there are no duplicate elements, return false.
        return false;
    }
}

Explanation

  • HashSet internally uses HashMap. Therefore, you can achieve the same result using HashSet.

What is Java Ternary Operator(?:)

Definition

The question mark operator (? :) is a conditional operator that selects one of two expressions based on the evaluation result of a condition. It can achieve results similar to an if statement.

Structure

if (Condition) { result = expression1; } else { result = expression2; }

result = Condition ? expression1 : expression2;

It is equivalent to an if statement.


Considerations for Use

When using the ternary operator, the following considerations should be taken into account:

Advantages

  • Code Conciseness: It allows expressing logic where a value is chosen based on a condition in a single line, enhancing code readability and conciseness.
  • Expression Reusability: The selected expression can be assigned to a variable or used as part of other expressions, thus increasing reusability.

Disadvantages

  • Readability of Complex Conditions: While the ternary operator is suitable for simple conditions, it may reduce readability for complex condition expressions. In such cases, using if-else statements might be more appropriate.

Step-by-Step Usage

  1. Write the condition expression. The condition expression should evaluate to a boolean value (true or false).
  2. Follow the condition expression with a question mark (?).
  3. Write the expression to be selected if the condition is true, followed by a colon (:).
  4. Write the expression to be selected if the condition is false.
  5. The result of the ternary operator is the value of the selected expression.

Example

int age = 18;
String message = (age >= 18) ? "You are an adult." : "You are a minor.";

System.out.println(message); // Output: "You are an adult."

In the example above, the value of the age variable is 18 or older, so the condition (age >= 18) evaluates to true. Therefore, the expression1, "You are an adult.", is selected and assigned to the message variable.

Java Operator Precedence

Java Operator Precedence Table

Operator Precedence Definition

Operator precedence is not about calculating operations based on priority. When there are multiple operators in a complex expression, operator precedence is used to group them.

This does not determine the order of execution of operations.

Example

Suppose we have the following expression, and the computer needs to decide whether to evaluate a > 0 first or 0 && b.

int a = 1, b = 1;
a > 0 && b - ++a == 1;

Following the Java Operator Precedence Table, we start grouping the expression:

a > 0 && b - ++a == 1;

a > 0 && b - (++a) == 1;

a > 0 && (b - (++a)) == 1;

a > 0 && (b - (++a)) == 1;

(a > 0) && (b - (++a)) == 1;

(a > 0) && ((b - (++a)) == 1);

Now, we evaluate the Logical AND from left to right:

(1 > 0) && ((b - (++a)) == 1);

true && ((b - (++a)) == 1);

true && ((b - (++1)) == 1);

Next, we apply the pre-Increment unary operator, increasing the operand's value by 1 before other calculations:

true && ((b - 2) == 1);

true && ((1 - 2) == 1);

true && (-1 == 1);

true && false;

false;

Increment and Decrement Operators

Operator Description
++A Increases the operand's value by 1 before other calculations
--A Decreases the operand's value by 1 before other calculations
A++ Increases the operand's value by 1 after other calculations
A-- Decreases the operand's value by 1 after other calculations

Logical OR Operator

The logical OR operator (||) evaluates expressions from left to right. If the first expression is true, it doesn't evaluate the second expression, as only one true result is required.

(1 == 1) || (1 == 2);

In the above case, (1 == 1) is true, so (1 == 2) is not evaluated, and the result is immediately true.

2023년 7월 28일 금요일

LeetCode 42. Trapping Rain Water Java Solution

Problem

Trapping Rain Water - LeetCode

Problem-solving approach

  • At least three elements (1, 0, 1) are required to hold water, so we need a minimum of three elements.
  • Algorithm
  • We find the highest blocks on the left and right sides with respect to the position we want to check.


  • We can fill water up to the minimum of these two heights.
  • Now, we subtract the block's height at the position to get the height of the water that can be filled.

  • Repeat the process for all positions.
  • To use the above algorithm, we need to loop in advance to get the highest block on the right and left.

  • Below, you can see the necessary values for each position.




Github Link

https://github.com/eunhanlee/LeetCode_42_TrappingRainWater_Solution.git

Time Complexity: O(n), Space Complexity: O(n)

public class Solution {
    /**
     * Calculates the amount of water that can be trapped between bars.
     *
     * @param height An array representing the height of the bars
     * @return The total amount of water trapped between bars
     */
    public static int trap(int[] height) {
        int n = height.length;
        if (n <= 2) {
            return 0;
        }

        // An array to store the maximum heights of the bars on the left side of each index
        int[] leftMax = new int[n];
        // An array to store the maximum heights of the bars on the right side of each index
        int[] rightMax = new int[n];
        // A variable to store the total amount of trapped water
        int maxWater = 0;

        // Calculate the maximum heights of the bars on the left side of each index
        leftMax[0] = height[0];
        for (int i = 1; i < n; i++) {
            leftMax[i] = Math.max(leftMax[i - 1], height[i]);
        }

        // Calculate the maximum heights of the bars on the right side of each index
        rightMax[n - 1] = height[n - 1];
        for (int i = n - 2; i >= 0; i--) {
            rightMax[i] = Math.max(rightMax[i + 1], height[i]);
        }

        // Calculate the trapped water for each bar
        for (int i = 1; i < n - 1; i++) {
            // Find the minimum height between the current bar's left and right highest bars
            int minBarHeight = Math.min(leftMax[i], rightMax[i]);
            // If the minimum bar height is greater than the current bar's height,
            // water can be trapped on top of the current bar.
            if (minBarHeight > height[i]) {
                // The trapped water amount is the difference between the minimum bar height and the current bar's height.
                maxWater += minBarHeight - height[i];
            }
        }

        // Return the total amount of trapped water.
        return maxWater;
    }
}

LeetCode 771. Jewels and Stones Java Solution

Problem

Jewels and Stones - LeetCode

Solution Approach

  • This problem is about checking whether each character from one input string exists in another input string.
  • Since each character needs to be checked at least once, the time complexity is O(n^2), where n is the length of the input string.
  • It tests your basic string handling skills.
  • To solve it, you need to understand the toCharArray() method and how to compare characters using the char data type in Java.

Java's Primitive Data Types and Reference Data Types

Github Link

https://github.com/eunhanlee/LeetCode_771_JewelsandStones_Solution.git

Time Complexity: O(n^2), Space Complexity: O(1)

class Solution {
    /**
     * Method to count the number of jewels in the stones.
     *
     * @param jewels The string representing types of jewels.
     * @param stones The string representing the stones you have.
     * @return The number of jewels found in the stones.
     */
    public int numJewelsInStones(String jewels, String stones) {
        int counter = 0;

        for (char stone : stones.toCharArray()) {
            for (char jewel : jewels.toCharArray()) {
                if (stone == jewel) {
                    counter++;
                }
            }
        }

        return counter;
    }
}

Java's Primitive Data Types and Reference Data Types

Primitive Types

  • There are a total of 8 primitive types predefined and provided.
  • As they have default values, they do not have Null.
  • They are stored in the stack memory, which is the space for storing actual values.
  • String is an object and not a primitive type.

Reference Types

  • All types except primitive types are reference types.
  • Null, which represents an empty object, exists in reference types.
  • The space for storing the address value of the location where the value is stored is in the heap memory.
  • There are no syntax errors, but runtime errors occur when using Null for objects or arrays, leading to a NullPointException. Therefore, variables should be assigned values.

LeetCode 35. Search Insert Position Java Solution

Problem

Search Insert Position - LeetCode

Problem Solving Approach

  • The given problem deals with a sorted array.
  • The condition is to solve it in O(log n) time complexity.
  • The only method to achieve this in a sorted list is Binary Search.
  • This problem tests your understanding of Binary Search and its implementation.
  • When implementing Binary Search, you need to decide whether to use recursion or iteration.
  • Since this problem does not require previous results or sub-problems, it is more effective to implement it using iteration.
  • When the target value is not found, the function should return the index where the target should be inserted.
  • The function returns 'low' value because it is closer to the target than 'high', where 'mid' is unchanged and 'mid' divided by 2 and floored is less than or equal to 'high'.

Github Link

https://github.com/eunhanlee/LeetCode_35_SearchInsertPosition_Solution.git

Time Complexity: O(log n), Space Complexity: O(1)

class Solution {
    /**
     * Search for the insertion position of the target value in the given sorted array.
     *
     * @param nums   Sorted integer array.
     * @param target Value to search for.
     * @return The index where the target should be inserted.
     */
    public int searchInsert(int[] nums, int target) {
        int low = 0;
        int high = nums.length - 1;

        while (low <= high) {
            int mid = low + (high - low) / 2;

            if (nums[mid] == target)
                return mid; // Return the index if the target value exists.
            else if (nums[mid] < target)
                low = mid + 1; // Move to the right half if the target is greater than the current middle value.
            else
                high = mid - 1; // Move to the left half if the target is less than the current middle value.
        }

        // If the loop exits, it means the target does not exist in the array, and 'low' indicates the insertion position.
        return low;
    }
}

2023년 7월 24일 월요일

LeetCode 1603. Design Parking System Solution

Problem

Design Parking System - LeetCode

Approach to Problem Solving

  • This is a question about object creation in Java.
  • The first solution demonstrates basic object creation, making it suitable for collaboration and future updates.
  • The second solution is highly efficient for this specific problem, but it might be challenging to update later.

Github Link

https://github.com/eunhanlee/LeetCode_1603_DesignParkingSystem_Solution.git

1st Solution

class ParkingSystem {
    private int bigSlots;
    private int mediumSlots;
    private int smallSlots;

    /**
     * Creates a new ParkingSystem with specified slots for each vehicle type.
     *
     * @param big    Number of available slots for big vehicles.
     * @param medium Number of available slots for medium vehicles.
     * @param small  Number of available slots for small vehicles.
     */
    public ParkingSystem(int big, int medium, int small) {
        this.bigSlots = big;
        this.mediumSlots = medium;
        this.smallSlots = small;
    }

    /**
     * Adds a vehicle of the given type to the parking system.
     *
     * @param carType Type of the vehicle to be parked (1 for big, 2 for medium, 3 for small).
     * @return True if the vehicle is successfully parked, otherwise false.
     */
    public boolean addCar(int carType) {
        switch (carType) {
            case 1:
                if (this.bigSlots > 0) {
                    this.bigSlots--;
                    return true;
                }
                break;
            case 2:
                if (this.mediumSlots > 0) {
                    this.mediumSlots--;
                    return true;
                }
                break;
            case 3:
                if (this.smallSlots > 0) {
                    this.smallSlots--;
                    return true;
                }
                break;
        }
        return false;
    }
}

2nd Solution

class ParkingSystem {
    int[] slots;

    /**
     * Creates a new parking system with given slot sizes.
     *
     * @param big    Number of slots available for big vehicles.
     * @param medium Number of slots available for medium vehicles.
     * @param small  Number of slots available for small vehicles.
     */
    public ParkingSystem(int big, int medium, int small) {
        slots = new int[]{big, medium, small};
    }

    /**
     * Adds a vehicle of the given type to the parking system.
     *
     * @param carType Type of the vehicle to be parked (1 for big, 2 for medium, 3 for small).
     * @return True if the vehicle is successfully parked, otherwise false.
     */
    public boolean addCar(int carType) {
        return --slots[carType - 1] >= 0;
    }
}

Reference

Reasons for Using 'this' Keyword in Java Object Creation

What is Short Circuit Evaluation

Short Circuit Evaluation

Short Circuit Evaluation refers to the behavior in logical AND and OR operations where the result can be determined without evaluating the remaining operands if the outcome is already certain.

Applicable Programming Languages

As of the current date in 2023, Short Circuit Evaluation is confirmed to be applicable in C, C++, Java, and Python.

Short Circuit Evaluation in AND Operation

In the case of AND operation, if the first operand evaluates to false, the remaining operands are skipped, and the result is determined as false.

Short Circuit Evaluation in OR Operation

For the OR operation, if the first operand evaluates to true, the remaining operands are skipped, and the result is determined as true.

Reasons for Using 'this' Keyword in Java Object Creation

Question

What is the difference between using and not using the 'this' keyword in Java?

Overview

Using and not using the 'this' keyword in Java has differences in preventing variable collisions, method chaining, readability, and clarity.

Reasons

  • Preventing variable collisions: When the parameter name of a method is the same as an instance variable, using 'this' helps differentiate between the instance variable and the parameter.
  • Method chaining: By returning 'this,' it allows consecutive method calls on the same object.
  • Readability and clarity: 'this' provides a clear reference to instance variables or methods, improving code readability and clarity.

Differences

  • When using 'this':
public class MyClass {
    private int value;

    public void setValue(int value) {
        this.value = value; // Using the "this" keyword to refer to the instance variable
    }
}
  • When not using 'this':
public class MyClass {
    private int value;

    public void setValue(int newValue) {
        value = newValue; // Directly referring to the instance variable
    }
}

Example

Preventing variable collisions

Using the 'this' keyword helps prevent variable collisions when the method's parameter name is the same as an instance variable name.

For example, consider the situation where the 'setValue' method has a parameter named 'value' which is the same as the instance variable 'value':

public class MyClass {
    private int value;

    public void setValue(int value) {
        this.value = value; // Using the "this" keyword to refer to the instance variable
    }
}

In this example, this.value refers to the instance variable, and value refers to the method parameter. This avoids variable collisions and correctly assigns the value to the intended variable.

Method chaining

Using 'this' allows implementing method chaining, which means consecutively calling methods on the same object.

public class MyClass {
    private int value;

    public MyClass setValue(int value) {
        this.value = value;
        return this; // Returning the same object to enable method chaining
    }

    public MyClass printValue() {
        System.out.println(value);
        return this;
    }
}
MyClass obj = new MyClass();
obj.setValue(10).printValue(); // Method chaining

In the above example, the 'setValue' method returns 'this', and the 'printValue' method also returns 'this'. This allows method chaining as shown in the code snippet.

Readability and clarity

However, using the 'this' keyword is not always mandatory. If a method does not reference instance variables and only uses parameters, the 'this' keyword can be omitted.

public class MyClass {
    public void printName(String name) {
        System.out.println("Hello, " + name);
    }
}

When not using 'this' to refer to instance variables or methods, it is assumed that those variables or methods belong to the current object. This may introduce some ambiguity in readability and clarity. Therefore, the 'this' keyword should be used when necessary, based on the readability and purpose of the code.

Conclusion

Using the 'this' keyword helps prevent variable collisions, enables method chaining, and improves code readability and clarity. However, it is not always mandatory, and the decision to use 'this' depends on the specific context and requirements.

2023년 7월 22일 토요일

How to Tamper Response in Burp Suite

Response Tampering

There are two methods to tamper with responses using Burp Suite:

  1. Modify the response code after intercepting the response.
  2. Set up proxy settings to intercept specific codes and replace them with different content.

Modifying the response code after intercepting:

  1. Open the browser with proxy intercept enabled.
  2. Navigate to the desired website using the opened browser.
  3. Turn on intercept by clicking "Intercept is off" and changing it to "Intercept is on."
  4. The request will pause until you click "Forward" after intercepting it.
  5. When it's paused, right-click and select "Do intercept-response to this request."
  6. After modifying the response, click "Forward" to see the changes in the Chromium browser.
  7. You can either modify the response and click "Forward" or turn off intercept to proceed.

Setting up proxy rules for response code manipulation:

  1. Go to Proxy > Options > Match and Replace Rules.
  2. Click "Add" to create a new rule.
  3. Select "Response Body" for the type.
  4. Enter <script>location.href='./example.php';</script> in the "Match" field.
  5. Leave the "Replace" field empty, as we want to remove the code <script>location.href='./example.php';</script>.
  6. Click "OK" to add the rule, and it will be applied to all future responses' body parts that contain the specified code.

How to Make Requests with Chrome Developer Tools

How to Make Requests

  1. Open the developer tools on the web page (for Chrome, press F12).
  2. Go to the console.
  3. Enter the JavaScript function, for example: goMenu('1018','admin');.
  4. Press Enter to execute the function.

Example

JavaScript Code

function user_auth_check(needLevel, userLevel){

	if(needLevel == userLevel){
		return true;
	}else{
		return false;
	}
}

function goMenu(code, userLevel){
	switch (code){
		case '1018':
			if(user_auth_check('admin',userLevel)){
				location.href="./fire_nuclear_Attack.php";
				break;
			}else{
				alert('You do not have permission.');
				break;
			}
		case '1129':
			location.href="./logout.php";
			break;
		default:
			alert('This menu does not exist.');
	}
}

Webpage Button Code

<a class="btn btn-lg btn-danger" href="#" role="button" onclick="goMenu('1018','')">Fire</a>

LeetCode 116. Populating Next Right Pointers in Each Node Java Solution

Problem

Populating Next Right Pointers in Each Node - LeetCode

Approach

  • Given a basic tree, the task is to connect its nodes.
  • Essentially, we need an algorithm to traverse the tree in level order and connect each node accordingly.
    • The problem assumes a perfect binary tree, meaning there are no empty nodes.
    • At level 1, connect all nodes at level 2.
    • Set the level's leftmost node as levelStart.
    • Connect the next node with its sibling (since the upper level is already connected, moving is easy).
    • If the next node's left child does not exist, it means the current level is fully connected.
  • BFS (level order) or recursive function can be used.
  • Recursive functions are often used when they can simplify complex tasks. However, this problem only requires a simple level order traversal without the need for previous calculated values, making recursion unnecessary.
  • Moreover, if the tree is large, there is a possibility of a stack overflow, so it's better to avoid recursion.

Github Link

https://github.com/eunhanlee/LeetCode_116_PopulatingNextRightPointersinEachNode_Solution.git

Time Complexity: O(n), Space Complexity: O(1)

class Solution {
    /**
     * Connects each node of the given binary tree with its right pointer.
     *
     * @param root The root node of the binary tree
     * @return The root node of the connected binary tree
     */
    public Node connect(Node root) {
        if (root == null)
            return null;

        // The leftmost node of the level
        Node levelStart = root;

        while (levelStart.left != null) {
            // Current node
            Node curr = levelStart;

            while (curr != null) {
                // Set the left child's next pointer to the right child
                curr.left.next = curr.right;
                // Set the right child's next pointer to the left child of the next node
                if (curr.next != null) curr.right.next = curr.next.left;
                // Move to the next node in the same level
                curr = curr.next;
            }

            // Move to the leftmost node of the next level
            levelStart = levelStart.left;
        }

        return root;
    }
}

2023년 7월 21일 금요일

LeetCode 2114. Maximum Number of Words Found in Sentences Java Problem Solving

 

Problem

Maximum Number of Words Found in Sentences - LeetCode

Solution Approach

  • This problem is about counting the number of words in a sentence and finding the maximum count among all sentences.

  • You should be familiar with loops, counting words, and finding the maximum value to solve this problem.

  • Algorithm:

    • Use a loop to iterate through each sentence.

    • Calculate the number of words in each sentence.

    • Compare the word counts to find the maximum value.

  • There are several ways to achieve this, such as different types of loops (for loop, while loop, advanced for loop), word counting methods (using split to split the sentence and count the words, or using character arrays to find the number of spaces and adding 1), and finding the maximum value (using if statements for comparison, using the ternary operator ? for comparison, or using Math.max).

  • The provided code uses an advanced for loop, split method to count words, and Math.max for comparison to solve the problem.

Github Link

https://github.com/eunhanlee/LeetCode_2114_MaximumNumberofWordsFoundinSentences_Solution

Time Complexity: O(nm), Space Complexity: O(1)

public class Solution {
    /**
     * Finds the maximum number of words in the given array of sentences.
     *
     * @param sentences An array of strings representing sentences.
     * @return The maximum number of words found in any sentence.
     */
    public int mostWordsFound(String[] sentences) {
        int max = 0;

        for (String sentence : sentences) {
            max = Math.max(max, sentence.split(" ").length);
        }

        return max;
    }
}

Setting up Anaconda and PyCharm virtual environments: Step-by-step guide

 

Definition

Anaconda is a package for Python and R languages, providing a convenient conditional free open-source package manager that manages dependencies and distributions.

Since 2020, it has become free only for individual users, universities, non-profit organizations, and small businesses with less than 200 employees. It is now a paid service for government and companies with 200 or more employees.

Reasons to Use Virtual Environments

The reason for using Anaconda is to manage the libraries and versions of Python. By setting up and naming virtual environments, you can easily keep track of the versions and libraries stored in each environment. This makes it convenient to move environments to different locations or reinstall them when needed.

Setting up Anaconda Virtual Environments

Anaconda Installation

  1. Download Anaconda from https://www.anaconda.com/ and install it.
  2. It is recommended to use the default installation path.
  3. If you choose a different installation path, additional configurations may be required based on the IDE you use.
  4. The default path is usually C:\Users\[your computer account name]\anaconda3.

Configuration in PyCharm

When creating a new project in PyCharm, you can create a new virtual environment.

Installing Libraries in PyCharm

Sometimes, the default terminal in PyCharm is PowerShell. In such cases, you need to activate the virtual environment and then install libraries.

To activate the virtual environment:

conda activate (virtual environment name)

Controlling Virtual Environments with Anaconda Console

Opening Anaconda Prompt

Start menu - Anaconda Prompt

Finding Possible Python Versions

conda search python

Creating a Virtual Environment

conda create -n (virtual environment name) python=(desired version)

After that, a list of packages to be installed will be displayed. Type 'y' to proceed with the installation.

Activating the Virtual Environment

If the activation is successful, you will see the virtual environment name instead of (base) in the terminal.

From: (base)current/path>

To: (virtual environment name)current/path>

conda activate (virtual environment name)

Deactivating the Virtual Environment

conda deactivate

Listing Virtual Environments

conda env list

Logic Gate Truth Tables & Definitions

Logic Gate Truth Tables Java Code !A // NOT A&B // AND ~(A&B) // NAND A|B // OR ~(A|B) // XOR A^B // XOR ~(A^B) // XNOR ~A // Inve...