Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Two Sum - Java

A Java implementation of the Two Sum problem using arrays and a nested-loop approach.

📌 Problem

Given an array of integers and a target value, find pairs of elements whose sum is equal to the target.

💡 Approach

This program uses a Brute Force approach:

  1. Take the size of the array as input.
  2. Take array elements from the user.
  3. Take the target value.
  4. Compare every possible pair of elements.
  5. If the sum of a pair equals the target, display the pair.
  6. If no pair is found, display a message.

🛠️ Technologies Used

  • Java
  • Arrays
  • Loops
  • Scanner
  • Basic Problem Solving

⏱️ Complexity

  • Time Complexity: O(n²)
  • Space Complexity: O(n)

▶️ How to Run

  1. Make sure Java is installed.

  2. Clone this repository.

  3. Compile the program:

    javac Two_sum.java#
    
    

4.Run the program: java Two_sum

📚 Learning Outcome

This project helped me practice:

  • Arrays
  • Nested loops
  • User input
  • Conditional statements
  • Brute Force problem solving
  • Time and space complexity

👨‍💻 Author

Nikhil

BCA Student | Java & Software Development Learner

About

Java solution for Two Sum problem using Array concept .

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages