We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b448d22 commit f38fb79Copy full SHA for f38fb79
searchInsertt.java
@@ -0,0 +1,19 @@
1
+class Solution {
2
+ public int searchInsert(int[] nums, int target) {
3
+ int index = 0;
4
+ if (nums[nums.length-1] < target) { index = nums.length; }
5
+ else if (nums[nums.length-1] == target){ index = nums.length-1;}
6
+
7
+ else {
8
+ for (int a =0; a< nums.length-1; a++){
9
10
+ if(nums[a] == target){
11
+ index = a;
12
+ }
13
+ else if ((nums[a]< target) && (nums[a+1] > target) ) { index = a+1;}
14
15
16
17
+ return index;
18
19
+}
0 commit comments