Count Frequency of a Number in a Sorted Array

Count Frequency of a Number in a Sorted Array.

Given a sorted array and a number k. We have to write a code to count how many times a number k appears in a sorted array.

For example –

Input: { 1, 4, 7, 8, 8, 11, 11, 11, 11, 12, 13 }, k = 11

Output: 4

In this input array, The number 11 appears Four time.

Product of Array Except Self

In this tutorial, I am going to discuss a very interesting problem Product of array except self or product of every integer except the integer at that index.

Given an array of N integers where N > 1. Write a code to print the result/output such that result[i] is equal to the product of all the elements of an array except self (result[i]).

For example –

Input: {4, 2, 1, 7}

Output: {14, 28, 56, 8}

NOTE: We have to solve this problem without division and in linear time O(n).

Reverse a Linked List

Given a singly linked list, write a code to reverse a linked list. In this tutorial, you are going to learn how to reverse a linked list in java using iterative approach.

For example –

Input linked list.

15 -> 9 -> 8 -> 5 -> NULL

When we reverse this linked list then the output is given below.

5 -> 8 -> 9 -> 15 -> NULL

In input linked list, head points to a node whose value is 15 but when it’s reversed the head points to a node whose value is 5.