{"id":19951221,"url":"https://github.com/emilwijayasekara/leetcode-1-twosum","last_synced_at":"2025-10-05T22:45:09.607Z","repository":{"id":212516856,"uuid":"731679407","full_name":"EmilWijayasekara/LeetCode-1-TwoSum","owner":"EmilWijayasekara","description":"LeetCode Problem 1.Two Sum - This repository contains my solution to the classic \"Two Sum\" problem from LeetCode. The problem entails finding two numbers in an array that sum up to a given target.","archived":false,"fork":false,"pushed_at":"2023-12-17T07:32:10.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-01T14:43:33.057Z","etag":null,"topics":["java","leetcode","leetcode-java","leetcode-solutions"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EmilWijayasekara.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-14T16:12:14.000Z","updated_at":"2023-12-17T06:50:03.000Z","dependencies_parsed_at":"2023-12-17T08:27:36.793Z","dependency_job_id":"b58ccdd2-b9cb-42bc-8391-4e09c8398520","html_url":"https://github.com/EmilWijayasekara/LeetCode-1-TwoSum","commit_stats":null,"previous_names":["emilwijayasekara/leetcode-1-twosum"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/EmilWijayasekara/LeetCode-1-TwoSum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmilWijayasekara%2FLeetCode-1-TwoSum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmilWijayasekara%2FLeetCode-1-TwoSum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmilWijayasekara%2FLeetCode-1-TwoSum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmilWijayasekara%2FLeetCode-1-TwoSum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EmilWijayasekara","download_url":"https://codeload.github.com/EmilWijayasekara/LeetCode-1-TwoSum/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmilWijayasekara%2FLeetCode-1-TwoSum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278532356,"owners_count":26002345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","leetcode","leetcode-java","leetcode-solutions"],"created_at":"2024-11-13T01:07:13.787Z","updated_at":"2025-10-05T22:45:09.572Z","avatar_url":"https://github.com/EmilWijayasekara.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LeetCode Practice (Day 1)\r\n\r\nThis repository contains my solutions to various LeetCode problems. I use this space to practice coding, improve my algorithmic skills, and showcase my solutions.\r\n\r\n## About the problem\r\n- **Problem Number** : 1\r\n- **Problem Name** : Two Sum\r\n- **Problem difficulty** : Easy (51.25%)\r\n- **Category** : Algorithms\r\n- **Programming language used** - Java\r\n\r\nIn this problem we have integer array and target, solution must return indices of the two numbers in array such they add up to _target_ \r\ngiven examples are \r\n\r\n\u003eExample 1:\r\n\u003eInput: nums = [2,7,11,15], target = 9\r\n\u003eOutput: [0,1]\r\n\u003e ~ Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].\r\n\r\n\u003eExample 2:\r\n\u003eInput: nums = [3,2,4], target = 6\r\n\u003eOutput: [1,2]\r\n\r\n\u003eExample 3:\r\n\u003eInput: nums = [3,3], target = 6\r\n\u003eOutput: [0,1]\r\n\r\n## Approach Explanation\r\nIn the \"Two sum\" problem I iterated through the array elements checking if the target value and sum of the elements in the array were equal. This problem can be solved using two arrays. In this problem, we can't add the same number twice to get the target value so the second for loop must avoid used values.\r\n\r\n### If you have suggestions for improvement or would like to contribute to this solution, feel free to create a pull request. 🙌😇\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femilwijayasekara%2Fleetcode-1-twosum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femilwijayasekara%2Fleetcode-1-twosum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femilwijayasekara%2Fleetcode-1-twosum/lists"}