You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dsa-solutions/gfg-solutions/0003-at-least-two-greater-elements.md
+18-2Lines changed: 18 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -82,8 +82,24 @@ The problem is to find all elements in an array except the two greatest elements
82
82
}
83
83
};
84
84
```
85
-
86
85
</TabItem>
86
+
<TabItem value="Java" label="java">
87
+
<SolutionAuthor name="@ImmidiSivani"/>
88
+
```Java
89
+
class Solution {
90
+
public long[] findElements( long a[], long n)
91
+
{
92
+
// Your code goes here
93
+
long[] ans=new long[a.length-2];
94
+
Arrays.sort(a);
95
+
for(int i=0;i<a.length-2;i++){
96
+
ans[i]=a[i];
97
+
}
98
+
return ans;
99
+
}
100
+
}
101
+
```
102
+
</TabItem>
87
103
</Tabs>
88
104
89
105
@@ -122,4 +138,4 @@ Auxiliary Space: The auxiliary space complexity is $O(N)$ because the sorting al
122
138
123
139
-**Geeks for Geeks Problem:**[Geeks for Geeks Problem](https://www.geeksforgeeks.org/problems/at-least-two-greater-elements4625/1?page=1&difficulty=School&sortBy=difficulty)
124
140
-**Solution Link:**[At Least Two Greater Elements on Geeks for Geeks](https://www.geeksforgeeks.org/problems/at-least-two-greater-elements4625/1?page=1&difficulty=School&sortBy=difficulty)
0 commit comments