Found 2620 Articles for Java

Remove Duplicates from a String in O(1) Extra Space

Avinash Gupta
Updated on 23-Aug-2023 17:04:35

165 Views

In this problem, our task is to remove all the duplicate characters present in the string other than the first occurrence of every character. Also, it's required to solve the problem without using any extra space, and the Space complexity must be O(1). Various approaches are used in this article. The Boolean array is defined in one approach to determine the repetition of the characters where the index of Boolean array is mapped to each alphabet. In the second approach, the concept of the Bit manipulation is used to remove the repeated characters from the resultant string. Let's explore ... Read More

Sort Elements on the basis of the Number of Factors

Avinash Gupta
Updated on 23-Aug-2023 16:47:22

214 Views

In this problem, our task is to sort the array of integers based on several factors of numbers present in the array as a priority. The array is the best way to store similar types of elements in java. But if the number of factors becomes equal in any two numbers, then as a second priority, this algorithm sees numerical value. Factors are the numbers by which the given number is divisible entirely without leaving any remainder. This article uses various approaches to sort elements based on several factors. To show you some instances Instance-1 If Array = ... Read More

What does “!” mean in Java?

Priya Mishra
Updated on 23-Aug-2023 13:46:19

193 Views

Introduction Java supports eight types of operators; the “!” operator is one of them. In Java, an operator is a symbol used to execute operations. Operators are entities that can modify the values of operands. Java makes authoring, compiling, and debugging code simple. It is helpful in creating code that can be reused and applications that are modular. It was created with the goal of having a few implementation dependencies as feasible. Let’s discuss in detail about the Java operators, “!” operator and where to use it with some working examples. Java operators Operators in Java are symbols that are ... Read More

What is meant by object in Java?

Priya Mishra
Updated on 23-Aug-2023 13:40:23

85 Views

Introduction In real life, we can call tables, chairs, lamps, etc. objects as they have some attributes and functions. We can say that anything that has attributes or properties and some functionality like a lamp has a stand and a bulb and it can light up a room so it is an object. In Java also, we have objects and they have their own properties. Objects are basically the instance of the class and the class provides a blueprint for the creation of an object. Let’s have a brief discussion on objects and how to create an object in Java. ... Read More

How are Java and C++ related?

Priya Mishra
Updated on 23-Aug-2023 12:54:52

72 Views

Introduction These days, Java and C++ are widely utilized in competitive programming. These two programming languages are utilized generally in industry and competitive programming due to their impressive characteristics. C++ is a commonly used programming language due to its efficiency, fast speed, and dynamic memory use. In terms of software development, Java is incomparable to any other programming language. Java is extensively utilized in the IT sector. Now we will look into how Java and C++ are similar. What is Java? Java is an Object-Oriented programming, general-purpose, and high-level language. It is mainly used for coding web applications. Java ... Read More

What is the full form of Java?

Priya Mishra
Updated on 09-Feb-2024 11:26:55

440 Views

Full form of Java Java is not an abbreviation but some programmers made a full form. Basically, Java doesn’t have any full form or special meaning. This full form is used jokingly by the programmers. J Just A Another V Virtual A Accelerator

Minimum Number of Operations to move all Uppercase Characters before all Lower Case Characters

Neetika Khandelwal
Updated on 22-Aug-2023 17:58:44

82 Views

You are given a string 'str' that contains both uppercase and lowercase letters. Any lowercase character can be changed to an uppercase character and vice versa in a single action. The goal is to print the least possible instances of this process that are necessary to produce a string containing at least one lowercase character, followed by at least one uppercase character. Input Output Scenarios First possible solution: the first 4 characters can be converted to uppercase characters i.e. “TUTORial” with 4 operations. Input str = “tutoRial” Output 1 Second possible solution: the third character ... Read More

First Come, First Serve ñ CPU Scheduling | (Non-preemptive)

Neetika Khandelwal
Updated on 22-Aug-2023 17:41:30

347 Views

FCFS CPU Scheduling (First Come, First Serve) is a fundamental CPU scheduling mechanism that executes programs in the order they are added to the ready queue. In other words, the first process to come will be carried out first, and so on. Since it uses a non−preemptive scheduling technique, a process that has been allocated to the CPU will keep running until it is finished or enters a waiting state. Scenario 1 Let's take a look at an example to understand FCFS CPU scheduling in more detail. Suppose we have three processes with the following arrival times and burst times: ... Read More

Finding Optimal Page Size

Neetika Khandelwal
Updated on 22-Aug-2023 17:36:59

139 Views

Operating system has a concept known as the optimal page size that is affected by a number of variables, such as the system architecture, the amount of physical memory at hand, and the workload of the running applications. Steps/ Approach The following steps can be used to find the ideal page size: Step 1: Establish the system's design:Different CPU designs support varied page sizes. For instance, x86 CPUs typically offer 4KB page sizes, whereas ARM CPUs support 4KB, 16KB, or 64KB page sizes. Step 2: Calculate the physical memory capacity:The ideal page size depends on the physical memory capacity. Larger ... Read More

Find time taken to Execute the Tasks in A Based on the Order of Execution in B

Neetika Khandelwal
Updated on 22-Aug-2023 17:34:51

54 Views

The goal is to determine the minimum time required to complete the tasks in queue A based on the order of execution in queue B, given two queues A and B, each of size N, where: Pop this task and run it if the task identified at the head of queue B is also at the head of queue A. Pop the current task from queue A and push it at the end if the task discovered at the front of queue B is not also found at the front of queue A. One unit of time is ... Read More

Advertisements