Merge Two Sorted Arrays — October 6, 2026
You are given two integer arrays, nums1 and nums2, both sorted in nondecreasing order. Your task is to merge these two arrays into a single new sorted array.
Browse every programming guide — from beginner to advanced.
20 of 756 tutorials loaded
You are given two integer arrays, nums1 and nums2, both sorted in nondecreasing order. Your task is to merge these two arrays into a single new sorted array.
Given an array nums containing n distinct numbers in the range [0, n], your task is to return the only number in the range that is missing from the array. The array nums contains n distinct numbers. The numbers are guaranteed to be in the range [0, n]. n represents the length of…
Given an input string s, reverse the order of the words. A word is defined as a sequence of nonspace characters. Words in s will be separated by at least one space. The reversed string should not contain leading or trailing spaces. Multiple spaces between two words should be redu…
Given an array of integers nums, a pair (i, j) is called a good pair if nums[i] == nums[j] and i < j. Return the number of good pairs. Input: An array of integers nums. Constraints: 1 <= nums.length <= 100 1 <= nums[i] <= 100 Output: An integer representing the total count of goo…
This statement allows the user to use if block inside the other if block. And the inner if statement is executed only if the outer if statement’s condition is true. Syntax Syntax of nested if statement in C: nested if Flowchart: Example of nested if statement in C: The output of…
This post shows, How to remove all vowels from a string in java? with the help of replaceAll() method. Remove vowels from a string in java: Explanation:Removing vowels in java is easy, we will take the user input with the help of a Scanner class. we will use replaceAll() which ta…
in this tutorial, we will write a java program to find the sum of the Largest Forward Diagonal in an Arraylist (matrix). Java Program to find the sum of the Largest Forward Diagonal Output: Explanation:It calculates the sum of each forward diagonal and returns the sum of the larg…
A separate function( search_function()) will be created where the array pointer will be declared and the searched element along with the size of an array will be passed. The function will return 1 if any element matches with the searched element otherwise it will return 0. This C…
This C program calculates the sum of digits of a given number using recursion. Here’s a concise explanation: Output: Enter a number: 123 Sum of digits of a number: 6 Learn more on recursion.
Recursion refers to the function calling itself directly or in a cycle. Before we begin, you should have the knowledge of following in C Programming: This C program calculates the factorial of a given number using recursion and the ternary operator. Here’s a brief explanation:
The program takes the two numbers from the user and passes the reference to the function where the sum is calculated. You may go through the topic below. Output: Enter the first number: 15.5Enter the Second number: 20.5Sum of the result: 36.000000 This is a simple C program that…
In this tutorial, we will write a program to find a pairs of elements from an array such that for the input [a,b,c,d,e,f,g] we will get output as ab,cd,ef,g Javascript and Python program to concatenate the string element in an array with its preceding string element. Javascript:…
In this tutorial, we will write various C pattern programs for String. Before that, you may go through the following topics in C. for loop in C C Pyramid String Pattern: 1 Enter the string: SIMPLE2CODEEnter the no. of rows: 8 S I M P L E 2 C O D E S I M … Read more
In this tutorial, we will write a program to find a pair of elements from an array whose sum equals a given number in java. Before that, you may go through the following topic in java. for loop in java if statement in java Algorithm to check the pair of similar numbers present in…
In this tutorial, we will learn to write a C program to print Diamond patterns using alphabets/characters. However, in this tutorial, we will create a character pattern in C using for loop. So you may go through the following topic in C. for loop in C Pattern 1: Diamond pattern i…
In this tutorial, we will learn and code the half diamond alphabet patterns in C programming language. However, in this tutorial, we will create a character pattern in C using for loop. So you may go through the following topic in C. for loop in C Pattern 1: Half Diamond pattern…
In this tutorial, we will learn and code alphabet patterns in C programming language specifically the Half pyramid of alphabets in C programming. However, in this tutorial, we will create a pyramid character pattern in C using for loop. So you may go through the following topic i…
In this tutorial, we will write a C program to print half Pyramid using alphabets/characters. Before that, you may go through the following topic in C. for loop in C Pattern 1: C program for character/alphabet. Enter the no. of rows: 6F F F F F FE E E E ED D D DC C … Read more
In this tutorial, we will write a C++ program to perform a multiplication on two complex numbers. Before that, you may go through the following topic in java. C++ function C++ struct C++ Program to Multiply two Complex Numbers using Struct Output: Enter first complex number (a+bi…
In this tutorial, we will write a Java program to print a multiplication table for any number. Before that, you may go through the following topic in java. Java – while loop Java Program to Print Multiplication Table using for loop Source code: The user needs to enter the number…