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
This repository was archived by the owner on Jun 29, 2025. It is now read-only.

Commit f6d18f8

Browse files
committed
Finished new problem
1 parent e456fc6 commit f6d18f8

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

‎Java/src/main/java/problems/leetcode/others/LongestCommonPrefix.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
class Solution {
1+
package problems.leetcode.others;
2+
3+
class LongestCommonPrefix {
24
public String longestCommonPrefix(String[] strs) {
35
String prefix = "";
46
int length = strs[0].length();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package problems.leetcode.others;
2+
3+
public class SearchInsertPosition {
4+
public int searchInsert(int[] nums, int target) {
5+
int pos = 0;
6+
for (int i = 0; i < nums.length; i++) {
7+
if (nums[i] == target) return i;
8+
if (nums[i] > target) return pos;
9+
pos++;
10+
}
11+
return nums.length;
12+
}
13+
}

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ Here is a list of the problems I've solved along with links to the corresponding
4141
| [Min Stack](https://leetcode.com/problems/min-stack/) | [Java](Java/src/main/java/problems/leetcode/stack/MinStack.java) |
4242
| [Evaluate Reverse Polish Notation](https://leetcode.com/problems/evaluate-reverse-polish-notation/) | [Java](Java/src/main/java/problems/leetcode/stack/ReversePolish.java) |
4343
| [3Sum](https://leetcode.com/problems/3sum/) | [Java](Java/src/main/java/problems/leetcode/two_pointers/ThreeSum.java) |
44-
| [Remove Element](https://leetcode.com/problems/kth-distinct-string-in-an-array) | [Java](Java/src/main/java/problems/leetcode/two_pointers/RemoveElement.java) |
44+
| [Remove Element](https://leetcode.com/problems/kth-distinct-string-in-an-array) | [Java](Java/src/main/java/problems/leetcode/two_pointers/RemoveElement.java) |
4545
| [Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix) | [Java](Java/src/main/java/problems/leetcode/others/LongestCommonPrefix.java) |
46+
| [Search Insert Position](https://leetcode.com/problems/search-insert-position/) | [Java](Java/src/main/java/problems/leetcode/others/SearchInsertPosition.java) |
4647
| [Roman to Integer](https://leetcode.com/problems/roman-to-integer) | [Java](Java/src/main/java/problems/leetcode/hash_table/RomanToInteger.java) |
4748
| [Roman to Integer](https://leetcode.com/problems/remove-element/) | [Java](Java/src/main/java/problems/leetcode/hash_table/KthDistinctStringInArray.java)|
4849

0 commit comments

Comments
(0)

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