Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write a Code [ Python, CPP, C, JAVA, JS ] to solve the Problem #1

Closed
saptarshisarkar20 opened this issue Oct 1, 2021 · 1 comment
Closed

Comments

@saptarshisarkar20
Copy link
Owner

Two Sum

Problem Link : https://leetcode.com/problems/two-sum/

Statement

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

You can return the answer in any order.

Example 1:

Input: nums = [2,7,11,15], 
target = 9
Output: [0,1]
Output: Because nums[0] + nums[1] == 9, we return [0, 1].

Example 2:

Input: nums = [3,2,4], 
target = 6
Output: [1,2]

Example 3:

Input: nums = [3,3], 
target = 6
Output: [0,1]

Constraints:

2 <= nums.length <= 
-109 <= nums[i] <= 109
-109 <= target <= 109
Only one valid answer exists.

Follow-up: Can you come up with an algorithm that is less than O(n2) time complexity?

RULES :

  • Star this repository.
  • Fork this repository
  • No need to wait for getting assigned, you can go ahead attempt the issues and raise a PR.
  • We will review any comments or PRs at 5 PM & 10 PM on 1st Oct, will give feedback if needed.

How to name your file?

  1. Go to folder : "/LeetCode/TwoSum/"
  2. Take today's date, i.e. 1stOct
  3. Take your GitHUB username id like "hrithik339", "hacker-boy", etc or anything which you have.
  4. File extension = say ".py" .
  • Combine all 3 to get your file name : Date + "_" + Username + File Extension, ex. "1stOct_hrithik339.py". Create this file in above mentioned folder only,

This will ensure no file will be conflict and any number of contributors can work on the same issue.
If you have any query ask in comments below, kindly follow this pattern strictly.

@nirmalya8
Copy link
Contributor

Pull request made on this issue. Added JAVA solution for the two-sum problem.

sayak2k1maruti added a commit to sayak2k1maruti/Novice-Coding that referenced this issue Oct 3, 2021
Big fan sir!
please accept my brute force solution 
later I'll learn the optimal solution from U in G-Meet class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants