From 8fa4b7fd1ba49ed7564d16ec866dc4202b6819c9 Mon Sep 17 00:00:00 2001 From: Sarthak <84651609+Sar-Go@users.noreply.github.com> Date: Sun, 25 Jun 2023 20:21:44 +0000 Subject: [PATCH 1/4] Initial Commit, added 2 solutions --- go/0912-sort-an-array | 4 ++++ go/1929-concatenation-of-array | 13 +++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 go/0912-sort-an-array create mode 100644 go/1929-concatenation-of-array diff --git a/go/0912-sort-an-array b/go/0912-sort-an-array new file mode 100644 index 000000000..18ac3ae7d --- /dev/null +++ b/go/0912-sort-an-array @@ -0,0 +1,4 @@ +func sortArray(nums []int) []int { + sort.Ints(nums) + return nums +} \ No newline at end of file diff --git a/go/1929-concatenation-of-array b/go/1929-concatenation-of-array new file mode 100644 index 000000000..29eabc2e2 --- /dev/null +++ b/go/1929-concatenation-of-array @@ -0,0 +1,13 @@ +func getConcatenation(nums []int) []int { + n := len(nums) + ans := make([]int, 2*n) //lets make an array of int type and 2*n size + + i := 0 + for i < n { //implementing for loop for the given condition + ans[i] = nums[i] + ans[i+n] = nums[i] + i++ + } + + return ans +} \ No newline at end of file From 4e794f46609898a6cb2805ebb936f673e730e9a0 Mon Sep 17 00:00:00 2001 From: Sarthak <84651609+Sar-Go@users.noreply.github.com> Date: Sun, 2 Jul 2023 11:30:32 +0530 Subject: [PATCH 2/4] Rename 0912-sort-an-array to 0912-sort-an-array.go [Resolved PR comment] added file extension --- go/{0912-sort-an-array => 0912-sort-an-array.go} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename go/{0912-sort-an-array => 0912-sort-an-array.go} (97%) diff --git a/go/0912-sort-an-array b/go/0912-sort-an-array.go similarity index 97% rename from go/0912-sort-an-array rename to go/0912-sort-an-array.go index 18ac3ae7d..74d42e6e7 100644 --- a/go/0912-sort-an-array +++ b/go/0912-sort-an-array.go @@ -1,4 +1,4 @@ func sortArray(nums []int) []int { sort.Ints(nums) return nums -} \ No newline at end of file +} From 4c0e22e46200338661969f676e9eb679bb34ee48 Mon Sep 17 00:00:00 2001 From: Sarthak <84651609+Sar-Go@users.noreply.github.com> Date: Sun, 2 Jul 2023 11:31:09 +0530 Subject: [PATCH 3/4] Rename 1929-concatenation-of-array to 1929-concatenation-of-array.go [Resolved PR Comment] Added .go extension to file name --- ...29-concatenation-of-array => 1929-concatenation-of-array.go} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename go/{1929-concatenation-of-array => 1929-concatenation-of-array.go} (99%) diff --git a/go/1929-concatenation-of-array b/go/1929-concatenation-of-array.go similarity index 99% rename from go/1929-concatenation-of-array rename to go/1929-concatenation-of-array.go index 29eabc2e2..281c3e03f 100644 --- a/go/1929-concatenation-of-array +++ b/go/1929-concatenation-of-array.go @@ -10,4 +10,4 @@ func getConcatenation(nums []int) []int { } return ans -} \ No newline at end of file +} From 0588c2e13d3234ecd7f0e5934a7a5a2a38aa867e Mon Sep 17 00:00:00 2001 From: Sarthak <84651609+Sar-Go@users.noreply.github.com> Date: Sun, 2 Jul 2023 11:33:28 +0530 Subject: [PATCH 4/4] Update 1929-concatenation-of-array.go --- go/1929-concatenation-of-array.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/go/1929-concatenation-of-array.go b/go/1929-concatenation-of-array.go index 281c3e03f..05d29edeb 100644 --- a/go/1929-concatenation-of-array.go +++ b/go/1929-concatenation-of-array.go @@ -1,13 +1,11 @@ func getConcatenation(nums []int) []int { n := len(nums) ans := make([]int, 2*n) //lets make an array of int type and 2*n size - i := 0 for i < n { //implementing for loop for the given condition ans[i] = nums[i] ans[i+n] = nums[i] i++ } - return ans }