
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

2K+ Views
A Linked List is a linear Data Structure that contains nodes and each node has two fields; one is the value or data to be inserted and the other field stores the address of the next node.Our task here is to delete a node from the end of a Linked List. The last node is known as the tail node. If there is no node in the Linked List, then return NULL.For example −Input 1 − 1 → 2 → 3 → 4 → 5Output − 1 → 2 → 3 → 4 →Explanation − In the given singly linked ... Read More

709 Views
Let us assume that we have given two unsorted arrays arr1[] and arr2[]. The task is to count the total number of elements in arr2[] for which each element of arr1[] are less than or equal to the elements present in arr2[]. However, the element in both the array may contain duplicates too.For example, Input-1 −N = 6 M = 7 arr1[N] = {1, 2, 5, 0, 6, 3} arr2[M] = {0, 0, 1, 2, 1, 3, 4, 6, 8}Output −4 5 7 2 8 6The approach used to solve this problemTo count every element of arr1[] and check if ... Read More

2K+ Views
ExamplesInput decimal_num = 13 => Output = 8+4+1 => 1101Input decimal_num = 11 => Output = 8+2+1 => 1011Approach to solve this problemStep 1: Define a function that accepts a decimal number, decimal_num, type is int.Step 2: Define an array to store the remainder while dividing decimal number by 2.Step 3: Start a for loop until the decimal number becomes 0.Step 4: Print the binary array in reverse order.ProgramLive Demopackage main import ( "fmt" ) func decimalToBinary(num int){ var binary []int for num !=0 { binary = append(binary, num%2) ... Read More

508 Views
We are given the length of a binary string str and the string itself. The task is to count the number of substrings that start with '1' and end with '1'. A binary string contains only '0's and '1's, and a substring is any continuous part of the given string. Let's look at a few example scenarios to understand the problem clearly: Scenario 1 Input: N = 5, str = "11101" Output: 6 Explanation: In the given binary string, there are 6 substrings that start and end with '1'. These are: ("11", "111", "1110", "11101", "1101", and "101"). Scenario ... Read More

2K+ Views
ExamplesInput binary_num = 1010111 => decimal number = 64+0+16+4+2+1 = 87Input binary_num = 10101 => decimal number = 21Approach to solve this problemStep 1: Define a function that accepts a binary number, binary_num, declare decimalNum = 0, index = 0Step 2: Start for loop until binary_num becomes 0.Step 3: Find the remainder of binary_num and divide by 10.Step 4: Calculate the decimal number using decimalNum and remainder*pow(2, index).Step 5: Return decimalNum.ProgramLive Demopackage main import ( "fmt" "math" ) func binaryToDecimal(num int) int { var remainder int index := 0 decimalNum := 0 for num ... Read More

4K+ Views
ExamplesInput arr = [1, 3, 4, 5, 6] => 1+3+4+5+6 = 19Input arr = [5, 7, 8, 9, 1, 0, 6] => 5+7+8+9+1+0+6 = 36Approach to solve this problemStep 1: Define a function that accepts an array.Step 2: Declare a variable, res = 0.Step 3: Iterate the array and add elements to res.Step 4: Return res.ProgramLive Demopackage main import "fmt" func findArraySum(arr []int) int{ res := 0 for i:=0; i

8K+ Views
Let's suppose we have given a number N. the task is to find the total number of digits present in the number. For example, Input-1 −N = 891452Output −6Explanation − Since the given number 891452 contains 6 digits, we will return ‘6’ in this case.Input-2 −N = 0074515Output −5Explanation − Since the given number 0074515 contains 5 digits, we will print the output as 5.The approach used to solve this problemWe can solve this problem in the following way, Take input ‘n’ as the number.A function countDigits(n) takes input ‘n’ and returns the count of the digit as output.Iterate over all ... Read More

333 Views
A good meal contains exactly two different food items with a sum of deliciousness equal to a power of two. You can pick any two different foods to make a good meal.Let us suppose we have given an array of integers arr where arr[i] is the deliciousness of the ith item of food, return the number of different good meals you can make from this list.For example, Input-1 −arr[ ] = {1, 3, 5, 7, 9}Output −4Explanation − The good meals are (1, 3), (1, 7), (3, 5) and, (7, 9). Their respective sums are 4, 8, 8, and 16, ... Read More

3K+ Views
ExamplesInput num = 1432 => output = 2341Input num = 9878 => output = 8789Input num = 6785 => output = 5876Approach to solve this problemStep 1: Define a function that accepts a number (num); type is int.Step 2: Define res = 0 variable and start a loop until num becomes 0.Step 3: Find remainder = num % 10 and make a number.Step 4: Divide num by 10.Step 5: Return res.ProgramLive Demopackage main import "fmt" func reverseNumber(num int) int { res := 0 for num>0 { remainder := num % 10 res = (res * 10) + remainder num /= 10 } return res } func main(){ fmt.Println(reverseNumber(168)) fmt.Println(reverseNumber(576)) fmt.Println(reverseNumber(12345)) }Output861 675 54321

3K+ Views
ExamplesInput arr = [3, 5, 7, 9, 10, 4] => [4, 10, 9, 7, 5, 3]Input arr = [1, 2, 3, 4, 5] => [5, 4, 3, 2, 1]Approach to solve this problemStep 1: Define a function that accepts an array.Step 2: Start iterating the input array.Step 3: Swap first element with last element of the given array.Step 4: Return array.ProgramLive Demopackage main import "fmt" func reverseArray(arr []int) []int{ for i, j := 0, len(arr)-1; i