-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmallerThanCurrent.cpp
More file actions
30 lines (29 loc) · 780 Bytes
/
SmallerThanCurrent.cpp
File metadata and controls
30 lines (29 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* Disclaimer:
This solution does not contain any header file or driver code, this only contains the class
and the algorithm used in this problem. You're probably learning DS and Algo because you
want to get into Competitive Programming or crack and interview, you should be acquainted with
this kind of solution.
TL;DR This is not the complete solution
*/
class Solution
{
public:
vector<int> smallerNumbersThanCurrent(vector<int> &nums)
{
vector<int> ans;
int freq = 0;
for (int x : nums)
{
for (int y : nums)
{
if (y < x)
{
freq++;
}
}
ans.push_back(freq);
freq = 0;
}
return ans;
}
};