Leetcode in Java && Oracle
421 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2021-10-23_16-53-56.png
38.9 KB
#N1365. How Many Numbers Are Smaller Than the Current Number
problem link=>https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/

#solution
class Solution {
public int[] smallerNumbersThanCurrent(int[] nums) {
int[] ans=new int[nums.length];
int count=0;
for(int i=0; i<nums.length; i++){
for(int j=0; j<nums.length; j++){
if(nums[i]>nums[j]&&j!=i){
count++;
}
}
ans[i]=count;
count=0;
}
return ans;
}
}