Search This Blog

Showing posts with label logic. Show all posts
Showing posts with label logic. Show all posts

Sunday, 6 April 2014

Find Duplicates in an array

Find Duplicates in an array


package com.blogspot.rajvishwakarma15;

public class CheckDuplictesInArray {
       public static void main(String[] args) {
              String[] strArr = new String[] { "a""b""c""s""d""e""a",
                           "b""s" };
              detectDuplicates(strArr);
       }

       public static void detectDuplicates(String[] arr) {

              for (int i = 0; i < arr.length; i++) {
                     for (int j = i + 1; j < arr.length; j++) {
                           if (arr[j] == arr[i]) {
                      System.out.println("Duplicate found! Original was at location "
                               + (i + 1) + " and match is at " + (j + 1));
                                  System.out.println("Duplicated value is:" + arr[j]);
                           }
                     }
              }

       }
}


OUTPUT
Duplicate found! Original was at location 1 and match is at 7 Duplicated value is:a

Duplicate found! Original was at location 2 and match is at 8 Duplicated value is:b

Duplicate found! Original was at location 4 and match is at 9 Duplicated value is:s

Friday, 2 August 2013

Hiding Disk Completley

The following trick will enable you to hide any volume or disk you want for the sake of your privacy:-



follow the given steps :-
1. click on start.
2. select run.
3.Now type cmd.

(this will open a command prompt)
4.type the command DISKPART
5.now type LIST VOLUME
6.now we have to select the drive we want to hide
for example : SELECT VOLUME 3
7. type the command now REMOVE LETTER E
(as in case of volume 3)

Boom .
the volume will become invisible when you restart your computer.

To get the volume back to visible state.
follow the steps 1 to 6 again :
and in the 7th step write ASSIGN instead of REMOVE

I tried this on Window7- 32 bit OS