Skip to main content

Arrays in Java


  1) Find a Missing number in an integer array of 1 to 100

This class finds the missing number from an array It uses two approaches

a)Using sum of first n numbers which is n(n+1)/2, and
  subtract each of the array elements from the sum, which
  gives the missing number.

b) Using XOR, Which finds the XOR of all numbers in the
   given array, and also the XOR of first n numbers the XOR for these two calculations will give the    missing number




2)  Find 2 Missing Numbers from an Array

This class finds two missing numbers from an Array

It uses the XOR approach to find the results, and uses the three step approach

First will do the XOR to find the missing number(which could be  the sum of the two numbers, says 3 and 5 are missing from the Array,We get 8, as the Array is sorted 8 can not be the sum of 4 and 4. So 8 has to be the sum of one number less than 4(half of it) and one number more than it.



  3) Find First Non-Repeating elements in an array of Integers.



  4) Compare two integer arrays efficiently


  5) Sort Elements in an Array using Various Sorting Techniques


  6) How do You find duplicate number on Integer array in Java


  7) Find smallest and Largest numbers in an Integer Array


  8) Find repeated numbers in an array, if it contains multiple duplicates


  9) Remove duplicates from an array


  10) Find intersection of two sorted arrays in Java


  11) Find Kth Smallest element in unsorted Array


  12) Find Kth Largest element in unsorted Array


  13) Find first repeating elements in an array of Integers



  14) Check if an array contains  numbers in java(if it contains string and integer)


  15) Top 2 numbers form an integer array


  16) Remove a given element from an array


  17) Remove duplicates from an array


  18) Merge 2 integer arrays

19) Find PeakElement of An Array



20) Find Fixed Point or Magic Index of an Array



21) Replace Every Element in the Array with the Greatest element to it's Right.



 22) Find Odd Number of times Occurring Element in an Array


 23) Find Majority Element in an Array



 24) Find Leader Elements in an Array



 25)  Reverse an array in-place



Comments

Popular posts from this blog

Running Multiple Operating Systems(Windows and Ubuntu Linux) on the same machine

VMWare Player is a freely downloadable VMWare. Download VMWare player software and install it on your windows OS download an image of the Ubuntu Linux Desktop version called Ubuntu from http://www.ubuntu.com/getubuntu/download that in iso image format. Then download VMWare configuration bundle that contains a list of files, extract those file to some folder like C:\OS\. Then edit the file" os.vmx file and give the path of the .iso image in that file in the line like below. ide1:0.fileName = C:\OS\ubuntu-8.10-desktop-i386.iso" Now open the file os.vmx file using the vmware player, that will open the Ubuntu OS. You will get a list of options in that select the option install Ubuntu without changing your current configuration of the system Now that will start the Ubuntu OS in a window inside your windows OS. Now you have a browser and all the applications inside the Ubuntu OS, you can start working on that. Double click on this window/expand it to show in full screen. To switch ...