Write a program to find maximum subarray sum in an array. Given an array of N elements, find the maximum possible sum of a contiguous subarray. An array can contain both positive and negative values.

### Categories

### Interview Questions

Technology Blog Where You Find Programming Tips and Tricks

Write a program to implement a queue using an array. In this tutorial, You are going to learn about Queue data structure and their implementation using an array in C, C++ & Java. In my previous posts, I have explained Stack and Linked List data structure.

In Queue data structure, An element is inserted at one end called **rear** and deleted at other end called **front.** As compared to stack data structure in which insertion and deletion are allowed only at one end. Queue data structure is also called **FIFO (First In First out)**.

Given **two sorted arrays**, Write a code to find common elements in two arrays. In other words, we have to write a code to find the intersection of two arrays.

Let’s assume following two sorted arrays arr1[] and arr2[].

int arr1[] = {2, 3, 4, 5, 6};

int arr2[] = {4, 6, 7, 8, 9};

Write a Program to find the second largest number in an unsorted array. Given an array of unsorted values find the second largest number in an array.

For example – Let’s take an array.

arr[] = { 4, 1, 5, 2, 8, 0, 3, 55}

The second largest element in this array is 8. So how do you find the second largest number in an array ? There are multiple ways by which you can solve this problem.

**First Approach : Sort an Array**

The simple approach is to sort an array using sorting algorithm. After sorting an array **element at n-2 index** will be the second largest element.

You can use following sorting algorithms.

ii) Insertion Sort

iii) Bubble Sort

iv) Merge Sort

Selection sort, insertion sort and bubble sort are not suitable for large data sets as their **time complexity** is **O(n ^{2})** . You can use Merge Sort or Quick Sort for large data sets.

NOTE– If values of an array is repeated then this approach won’t work. Then the best approach is to traverse an array to find the second largest element.

**Second Approach : Traverse an array**

The best approach is to traverse an array to find the second largest number in an array. Using this approach maintain two flags one for highest and other for the second highest number. The time complexity of this approach is O(n).

Given an unsorted array. How to find duplicates in array using PHP. These types of questions are generally asked in interviews. Sometimes interviewer allows to use in-built function sometimes not.

How to find missing number in array of 1 to n. This question is generally asked in technical interviews. The problem statement is something like that. Given an array of numbers from 1 to 100. The **array is sorted**. **One number is missing** from an array. You have to find the missing number from an array. Also there is no duplicates in an array.

Write a c program to reverse a string without using strrev function. Given an input string, we have to write a method to reverse a string. In c, you can simply reverse a string using an inbuilt strrev() function. But we don’t have to use this method.

Think how do you solve this problem. In this tutorial, we write a c code to reverse a string using stack, pointers, recursion, loop.

With every release of PHP new version, new functionality,improvement and bug fixes are released. PHP 5.4 introduces the concept of Generators and traits etc. Apart from new functionality, PHP 5.4 introduces many improvements one such improvement is shorter syntax of array declaration.