Popular Posts

July 10, 2024

How to Disable proxy in Laptop Windows 11

 

Disabling a proxy involves turning off a setting that reroutes your internet traffic through a different server before reaching its destination. Here’s how you can disable a proxy:

  1. Windows:

    • Open the Control Panel.
    • Go to "Network and Internet" and then click on "Internet Options".
    • In the Internet Properties window, go to the "Connections" tab.
    • Click on the "LAN settings" button.
    • Uncheck the box next to "Use a proxy server for your LAN".
    • Click "OK" to save your changes.
  2. Mac:

    • Click on the Apple menu and choose "System Preferences".
    • Select "Network".
    • Choose your network connection (Wi-Fi or Ethernet) from the list on the left.
    • Click on the "Advanced" button.
    • Go to the "Proxies" tab.
    • Uncheck any boxes next to "Web Proxy (HTTP)" and "Secure Web Proxy (HTTPS)".
    • Click "OK" to save your changes.

After disabling the proxy, restart your web browser and try accessing the webpage again to see if the issue is resolved. Disabling a proxy temporarily can help troubleshoot connectivity problems, especially if the proxy server is experiencing issues or misconfigured.


June 14, 2024

Java Programs to Find duplicate number between 1 to N numbers

 
Q: Find out duplicate number between 1 to N numbers

Description:

You have got a range of numbers between 1 to N, where one of the number is
repeated. You need to write a program to find out the duplicate number.

Code:

package com.java2novice.algos;

import java.util.ArrayList;
import java.util.List;

public class DuplicateNumber {

    public int findDuplicateNumber(List<Integer> numbers){
        
        int highestNumber = numbers.size() - 1;
        int total = getSum(numbers);
        int duplicate = total - (highestNumber*(highestNumber+1)/2);
        return duplicate;
    }
    
    public int getSum(List<Integer> numbers){
        
        int sum = 0;
        for(int num:numbers){
            sum += num;
        }
        return sum;
    }
    
    public static void main(String a[]){
        List<Integer> numbers = new ArrayList<Integer>();
        for(int i=1;i<30;i++){
            numbers.add(i);
        }
        //add duplicate number into the list
        numbers.add(22);
        DuplicateNumber dn = new DuplicateNumber();
        System.out.println("Duplicate Number: "+dn.findDuplicateNumber(numbers));
    }
}

Output:

Duplicate Number: 22