From 738b5a42b7e9a41861ad0559aa6603158050d5aa Mon Sep 17 00:00:00 2001 From: mudabbir-ahmad Date: Sun, 12 Apr 2026 22:03:20 +0100 Subject: [PATCH] add initial project files including .gitignore, editor settings, and Two Sum implementation --- .idea/.gitignore | 10 ++++ .idea/.name | 1 + .idea/Leet-Code-prog.iml | 2 + .idea/editor.xml | 101 +++++++++++++++++++++++++++++++++++++++ .idea/misc.xml | 7 +++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ CMakeLists.txt | 10 ++++ Easy/TwoSum/TwoSum.cpp | 20 ++++++++ Easy/TwoSum/TwoSum.h | 16 +++++++ Easy/TwoSum/TwoSum.md | 39 +++++++++++++++ 11 files changed, 220 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/.name create mode 100644 .idea/Leet-Code-prog.iml create mode 100644 .idea/editor.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 CMakeLists.txt create mode 100644 Easy/TwoSum/TwoSum.cpp create mode 100644 Easy/TwoSum/TwoSum.h create mode 100644 Easy/TwoSum/TwoSum.md diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..30cf57e --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..684ef01 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +Leet_Code_prog \ No newline at end of file diff --git a/.idea/Leet-Code-prog.iml b/.idea/Leet-Code-prog.iml new file mode 100644 index 0000000..4c94235 --- /dev/null +++ b/.idea/Leet-Code-prog.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/editor.xml b/.idea/editor.xml new file mode 100644 index 0000000..ca29dcc --- /dev/null +++ b/.idea/editor.xml @@ -0,0 +1,101 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0b76fe5 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..44a0b84 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..f738d43 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 4.2) +project(Leet_Code_prog) + +set(CMAKE_CXX_STANDARD 14) + +include_directories(Easy/TwoSum) + +add_executable(Leet_Code_prog + Easy/TwoSum/TwoSum.cpp + Easy/TwoSum/TwoSum.h) diff --git a/Easy/TwoSum/TwoSum.cpp b/Easy/TwoSum/TwoSum.cpp new file mode 100644 index 0000000..87d9848 --- /dev/null +++ b/Easy/TwoSum/TwoSum.cpp @@ -0,0 +1,20 @@ +// +// Created by bob on 12/04/2026. +// + +#include "TwoSum.h" + +class Solution { +public: + vector twoSum(vector& nums, int target) { + for (int j = 0; j < nums.size(); j++) + { + for (int i = 1; i < nums.size(); i++) + { + if (nums[j]+nums[i] == target) + { return {i, j}; } + } + } + return {}; + } +}; \ No newline at end of file diff --git a/Easy/TwoSum/TwoSum.h b/Easy/TwoSum/TwoSum.h new file mode 100644 index 0000000..1aa3752 --- /dev/null +++ b/Easy/TwoSum/TwoSum.h @@ -0,0 +1,16 @@ +// +// Created by bob on 12/04/2026. +// + +#ifndef LEET_CODE_PROG_TWOSUM_H +#define LEET_CODE_PROG_TWOSUM_H + + + +class TwoSum { + +}; + + + +#endif //LEET_CODE_PROG_TWOSUM_H diff --git a/Easy/TwoSum/TwoSum.md b/Easy/TwoSum/TwoSum.md new file mode 100644 index 0000000..f05e396 --- /dev/null +++ b/Easy/TwoSum/TwoSum.md @@ -0,0 +1,39 @@ +# 1. Two Sum +### Easy + +Hint +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]` + +Explanation: 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 <= 104` + +`-109 <= nums[i] <= 109` + +`-109 <= target <= 109` + +Only one valid answer exists.