1365. 有多少小于当前数字的数字
生活随笔
收集整理的這篇文章主要介紹了
1365. 有多少小于当前数字的数字
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2020-03-17
1.題目描述
有多少小于當前數字的數字2.題解
直接進行搜索即可3.代碼
#include <iostream> #include <vector> using namespace std;class Solution { public:vector<int> smallerNumbersThanCurrent(vector<int>& nums) {int l=nums.size();vector<int>res;for (int i=0;i<l;i++){int cnt=0;for (int j=0;j<l;j++){if (i!=j&&nums[i]>nums[j]) cnt++;}res.push_back(cnt);}return res;} };int main(){Solution s;vector<int> words={7,7,7,7},res;res=s.smallerNumbersThanCurrent(words);for (vector<int>::iterator i=res.begin();i!=res.end();i++){cout<<*i<<" ";}cout<<endl;return 0; }總結
以上是生活随笔為你收集整理的1365. 有多少小于当前数字的数字的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 55 - I. 二叉树的深度
- 下一篇: Codeforces 671D. Roa