Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 55c7359

Browse files
commit
1 parent 461b3f4 commit 55c7359

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

‎88. Merge Sorted Array.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Solution {
2+
public:
3+
void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
4+
int i = m - 1;
5+
int j = n - 1;
6+
int k = m + n - 1;
7+
8+
while (i >= 0 && j >= 0) {
9+
if (nums1[i] > nums2[j]) {
10+
nums1[k--] = nums1[i--];
11+
} else {
12+
nums1[k--] = nums2[j--];
13+
}
14+
}
15+
16+
17+
while (j >= 0) {
18+
nums1[k--] = nums2[j--];
19+
}
20+
}
21+
};

‎README.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1 @@
1-
# 📘 Leetcode_Array_cpp
2-
3-
This repository contains C++ solutions to array-related problems from LeetCode's official Array problem list.Each solution is written with clean code, proper comments, and optimal algorithms where possible.
4-
5-
# 🎯 Goal
6-
7-
To consistently solve and master array problems in C++ — improving problem-solving skills, logic, and speed for competitive programming and interviews.
8-
9-
10-
11-
12-
🤝 Contributing
13-
14-
This is a personal practice repo, but suggestions or pull requests for optimization, formatting, or better practices are always welcome.
15-
16-
17-
18-
⭐️ Support
19-
20-
If you like this repo, please give it a ⭐️ to motivate continued problem solving and documentation!
1+
# Leetcode_Array_cpp

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /