Maximum in Array Which is at Least Twice of Other Elements

Vaishnavi Tripathi
Updated on 05-Oct-2023 11:42:11

159 Views

In this article, we will discuss different approaches to point out the greatest element in the array which is at least twice of all the other elements in the same array. Problem Statement An array of n different elements is given to us, we have to find out the maximum element in the given array "nums" such that it is either greater than or equal to twice of all the other elements in that array. In other words, we can also say the we have to find out whether or not all the other elements of the given array are ... Read More

Largest Number That Is Not a Perfect Square

Vaishnavi Tripathi
Updated on 05-Oct-2023 11:34:32

206 Views

In this article, we will discuss two different approaches to find out the largest number smaller than a given number which is not a perfect square. In the first approach, we will run a loop to check for every number until we find the desired number while in the second approach, we will use the concept of square root to generate the perfect square number just smaller than the given number and based on this, we will find out the largest number smaller than "nums" which is not a perfect square. Let us first understand the problem statement. Problem Statement ... Read More

K Smallest Elements in Same Order Using O(1) Extra Space

Vaishnavi Tripathi
Updated on 05-Oct-2023 11:32:10

147 Views

We have an array "nums" consisting of "size" elements and an integer "number" denoting the number of smallest elements we have to return. Our task is to find out the "number" smallest elements from the given array. The order of the elements should be preserved and we are not allowed to use any extra variable space for the solution i.e., the space complexity of the solution should be O(1). Let us understand this using an example, nums = { 4, 2, 6, 5, 1 } The solution should return 4, 2, 5 as they are the smallest 3 ... Read More

Read and Write Class Objects to File in C++

Sunidhi Bansal
Updated on 05-Oct-2023 01:10:37

39K+ Views

The iostream standard library has two methods cin, to accept input from standard input stream and cout to print output to the standard output stream. In this article we will learn how to read data from files into class objects and how to write data in class objects to files.Reading and writing data to and from files requires another standard library of C++ . The three main data types of fstream are −ifstream − represents input file stream and reads information from files.ofstream − represents output file stream and writes information to files.fstream − represents general file stream and has ... Read More

Select Rows Where Column Contains String in MySQL

Ankith Reddy
Updated on 05-Oct-2023 01:06:33

40K+ Views

To select the row value containing string in MySQL, use the following syntax.SELECT *FROM yourTableName where yourColumnName like ‘%yourPattern%’;To understand the above syntax, let us first create a table. The query to create a table is as follows.mysql> create table PatternDemo -> ( -> Id int, -> Name varchar(100), -> Age int -> ); Query OK, 0 rows affected (0.97 sec)Insert records in the table using insert command. The query is as follows.mysql> insert into PatternDemo values(1, 'James', 23); Query OK, 1 row affected (0.11 sec) mysql> insert into PatternDemo values(2, 'Joseph', 21); Query OK, 1 row affected (0.18 ... Read More

Abstract Data Type in Data Structures

Arnab Chakraborty
Updated on 05-Oct-2023 01:03:30

38K+ Views

The Data Type is basically a type of data that can be used in different computer program. It signifies the type like integer, float etc, the space like integer will take 4-bytes, character will take 1-byte of space etc.The abstract datatype is special kind of datatype, whose behavior is defined by a set of values and set of operations. The keyword “Abstract” is used as we can use these datatypes, we can perform different operations. But how those operations are working that is totally hidden from the user. The ADT is made of with primitive datatypes, but operation logics are ... Read More

Difference Between Logical and Physical Address in Operating System

Kiran Kumar Panigrahi
Updated on 05-Oct-2023 01:01:27

43K+ Views

In computers, an address is used to identify a location in the computer memory. In operating systems, there are two types of addresses, namely, logical address and physical address. A logical address is the virtual address that is generated by the CPU. A user can view the logical address of a computer program. On the other hand, a physical address is one that represents a location in the computer memory. A user cannot view the physical address of a program. Read this article to find out more about logical and physical address and how they are different from each other. ... Read More

Add 2 Hours to a JavaScript Date Object

Saurabh Jaiswal
Updated on 05-Oct-2023 00:58:04

28K+ Views

In this tutorial, we will learn how to add 2 Hours to a JavaScript Date object. Here we will discuss two methods which are following. Using the getTime() Method Using the setHours() Method Using the getTime( ) Method JavaScript date getTime() method returns the numeric value corresponding to the time for the specified date according to universal time. The value returned by the getTime() method is the number of milliseconds since 1 January 1970 at 00:00:00. Syntax Following the syntax for the getTime() method − Date.getTime() Approach To add 2 hours to the Date Object first, we ... Read More

Difference Between LAN, MAN, and WAN

Kiran Kumar Panigrahi
Updated on 04-Oct-2023 21:49:14

27K+ Views

When several computers are connected together and are able to communicate with one another, it is called a computer network. Computer networks are designed to share data and information among the computers of the network. Depending on the operating geographical area, computer networks are of the three major types, namely LAN, MAN, and WAN. All the three computer networks are designed for the same purpose, i.e., for sharing information among the computers. But, they are different in many ways, which we are going to highlight in this article. Let's start with some basics of LAN, MAN, and WAN. What ... Read More

Add a Variable in HTML

Ramu Prasad
Updated on 04-Oct-2023 21:45:38

24K+ Views

Use the tag in HTML to add a variable. The HTML tag is used to format text in a document. It can include a variable in a mathematical expression. Example You can try to run the following code to add a variable in HTML −           HTML var Tag               The equations: 2x - 4z = 2y + 3 and          x + 5z = 3y + 6    

Advertisements