Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Coding Practice Articles
Found 21 articles
Java Program to Add Two Complex numbers
Complex numbers are expressed in the form of p + iq, where p and q indicate real numbers and i represents imaginary numbers. For instance, 8.2 + 5.6i is a complex number, where 8.2 is the real part and 5.6i is the imaginary part. As you can see, the real number part contains an integer value (mathematical, not Java integer), and the imaginary part has an additional symbol i. In this article, we will understand how to add two complex numbers in Java. Adding Complex Numbers Since complex numbers are divided into two parts (real and imaginary), the real numbers ...
Read MoreMinimum sum of differences with an element in an array
Problem Statement In this problem, we are given an array of integers, and we have to select a particular element from the array such that the sum of absolute differences between that element and all other elements is minimized. Example 1 Input: arr = [3, 1, 2, 5, 4] Output: 6 Explanation: If we select 3 as the element, the sum of differences is: |3-1| + |3-2| + |3-3| + |3-4| + |3-5|= 2 + 1 + 0 + 1 + 2 = 6 ...
Read MoreSort an array which contain 1 to n values
Sorting an array containing values from 1 to n means arranging the integers in their natural ascending order. This type of sorting problem is commonly encountered in competitive programming (for solving complex problems), where the array is guaranteed to have integers ranging from 1 to n. In this article, we will explore various approaches to solving this problem. In this problem, we are given an array containing values ranging from 1 to n in random order. Our goal is to sort the array in ascending order. Example 1 Input: int array[] = {3, 1, 2, ...
Read MoreJavaScript Program to Check if a Given Year is Leap Year
To check if a given year is leap year, We have used two approaches in this article. A leap year has 366 days. In every 4th year, an additional day is added to the month of February to synchronize it with astronomical year. In this article, we are given with two years to check. Our task is to write a JavaScript program to check if a given year is leap year. Approaches to Check Leap Year Here is a list of approaches to check if a given year is leap year in Javascript which we will be discussing ...
Read MoreMissing Number in an array in O(1) Time Complexity
Problem Description We are given an array that contains numbers from 1 to n, and one number is missing between the given numbers from 1 to n. We have to return the missing number in O(1) time complexity. In this problem, we are going to discuss how we can find the missing number in an array. Example 1 Input: array = {1, 2, 3, 5, 6, 7} Output: 4 Explanation From 1 to 7, the number 4 is missing in the given array. Example 2 ...
Read MoreHow to Prepare for Coding Interviews?
Getting hired by Top IT companies might be stressful, particularly when it comes to the coding job interview. However, don’t panic! It doesn’t matter if you are a novice coder or someone with years of experience, all coding interviews can be managed easily if you have the necessary preparation. This tutorial will offer a concise description of the fundamental skills and behaviors needed to succeed1. Make Sense of the Interview OutlineAchieving success in a coding interview with a target company begins with the client understanding the workflow. Here is something to look out forDummy Screening: One of the reviews and a ...
Read MoreBenefits of ipsum or dummy text for developers
Ipsum, also known as dummy text is an important tool for developers during planning and development stage. Teams can concentrate on format, features, and user satisfaction without being restricted to or inaccessible textual content due to its impartial content placeholder. This approach ensures clear communication among developers, designers, and stakeholders while simplifying the processes. Benefits of Ipsum or Dummy Text for DevelopersIpsum or dummy text provides the following benefits to developers - Pays Attention to Visual DesignDesigners and developers can focus on a project's visual elements by using placeholder text. It is possible to improve font patterns, sizes, alignment, and ...
Read Morecheck if a given array represent min-heap or not
A Heap is a Tree-based data structure in which the tree is a complete binary tree. Binary heap is of two types max heap and min heap. A min-heap is a tree-like structure in which the value of the parent node should always be less than both of its left and right child and follow this property recursively for all nodes until it reaches to leaf node. According to this property, the root node of the min-heap has the smallest value. In this article, we are going to check whether an array represents a min-heap or not. Problem Description We ...
Read MoreJava program to count set bits in an integer
In this article, we are given an integer value and the task is to count the total number of set bits of the given integer. For this task, we need to convert the given value into its corresponding binary representation. The binary number of an integer value is represented as the combination of 0's and 1's. Here, the digit 1 is known as the Set bit in the terms of the computer. Problem Statement Write a program in Java to count set bits in an integer − Input int num = 10 Output binary representation = 1010 set bit ...
Read MoreJAVA Program to Replace Each Element of Array with its Next Element
As per the problem statement we have to write a Java program to replace each element of the array with its next element. In Java, the array is an object. It is a non-primitive data type which stores values of similar data types. Before discussing the solution for the given problem, let's understand the problem statement with an example − Example Scenario: Input: arr[] = {12, 23, 11, 64} Output: updated array = {23, 11, 64, 12} Algorithm Follow the steps below to replace each element of the array with its next element − Step 1 − Declare ...
Read More