首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
右侧更小数
[编程题]右侧更小数
热度指数:1009
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 256M,其他语言512M
算法知识视频讲解
给定一个长度为 n 的数组 nums ,请你返回一个新数组 count ,其中 count[i] 是 nums[i] 右侧小于 nums[i] 的元素个数。
数据范围:
,数组元素值满足
示例1
输入
[9,8,7,6,5]
输出
[4,3,2,1,0]
示例2
输入
[5,7,8,9,6]
输出
[0,1,1,1,0]
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(0)
邀请回答
收藏(19)
分享
纠错
提交结果有问题?
5个回答
9篇题解
开通博客
牛客640386894号
发表于 2022-06-23 16:11:04
//定义线段树 class segtree{ public: segtree* leftNode = NULL; segtree* rightNode = NULL; int left = 0; int right = 0;
展开全文
牛客107722044号
发表于 2023-03-26 17:11:25
所以说,我想练练线段树来着 但是一看这题,二分查找不就时间够了 结果写了个二分查找就过了 emmm继续找线段树题去 import java.util.*; public class Solution { public ArrayList<Integer> smallerCoun
展开全文
17c89
发表于 2024-09-07 17:11:32
import java.util.*; /** * NC360 右侧更小数 * @author d3y1 */ public class Solution { private int[] index; private int[] result; /** *
展开全文
17c89
发表于 2024-10-04 15:36:39
import java.util.*; /** * NC360 右侧更小数 * @author d3y1 */ public class Solution { private int[] index; private int[] result; /** *
展开全文
17c89
发表于 2024-10-14 13:27:20
import java.util.*; /** * NC360 右侧更小数 * @author d3y1 */ public class Solution { // 树状数组t private int[] t; // 线段树 private int[] se
展开全文
江南蜡笔小新
发表于 2022-06-22 19:49:17
快排思想超时,用归并思想可以解决问题 和smallerSum没多大区别,思想还是传递已有信息 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param nums int整型一维数组 # @return int整型一维数组 # class Solu
展开全文
明明112358
发表于 2022-05-11 21:39:30
{ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); return nullptr; }(); class Solution { public: vector<int> index;
展开全文
牛暴发
发表于 2022-11-17 09:47:47
利用归并排序,逆序对出现,记录结果import java.util.*; public class Solution { public class Info{ private int v;//对应原来数组的值 private int i;//对应原来数组的
展开全文
17c89
发表于 2024-09-08 19:10:49
import java.util.*; /** * NC360 右侧更小数 * @author d3y1 */ public class Solution { private int[] index; private int[] result; /** *
展开全文
问题信息
线段树
分治
二分
排序
难度:
5条回答
19收藏
3653浏览
热门推荐
通过挑战的用户
查看代码
酋非天
2022-09-13 14:29:57
半个西瓜半个夏
2022-09-13 11:57:31
ji-li-k
2022-09-11 20:42:23
乖乖仔勋宝
2022-09-08 01:48:39
FM_NowC...
2022-09-03 10:08:01
相关试题
要求先给出思路,然后写代码,可以使...
北京搜狐互联网信息服务有限公司
查找
分治
评论
(3)
分组
基础数学
二分
评论
(11)
编程题:输入一个正整数,若该数能用...
网易
递归
分治
评论
(16)
在大语言模型中,什么是"Gated...
大模型开发
评论
(1)
关于大模型“上下文窗口”的理解,以...
大模型概念
评论
(1)
右侧更小数
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型ArrayList * @return int整型ArrayList */ public ArrayList
smallerCount (ArrayList
nums) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型vector * @return int整型vector */ vector
smallerCount(vector
& nums) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param nums int整型一维数组 # @return int整型一维数组 # class Solution: def smallerCount(self , nums ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型一维数组 * @return int整型一维数组 */ public List
smallerCount (List
nums) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型一维数组 * @return int整型一维数组 */ function smallerCount( nums ) { // write code here } module.exports = { smallerCount : smallerCount };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param nums int整型一维数组 # @return int整型一维数组 # class Solution: def smallerCount(self , nums: List[int]) -> List[int]: # write code here
package main import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型一维数组 * @return int整型一维数组 */ func smallerCount( nums []int ) []int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型一维数组 * @param numsLen int nums数组长度 * @return int整型一维数组 * @return int* returnSize 返回数组行数 */ int* smallerCount(int* nums, int numsLen, int* returnSize ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param nums int整型一维数组 # @return int整型一维数组 # class Solution def smallerCount(nums) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型一维数组 * @return int整型一维数组 */ def smallerCount(nums: Array[Int]): Array[Int] = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型一维数组 * @return int整型一维数组 */ fun smallerCount(nums: IntArray): IntArray { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型一维数组 * @return int整型一维数组 */ public int[] smallerCount (int[] nums) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型一维数组 * @return int整型一维数组 */ export function smallerCount(nums: number[]): number[] { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型一维数组 * @return int整型一维数组 */ func smallerCount ( _ nums: [Int]) -> [Int] { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型一维数组 * @return int整型一维数组 */ pub fn smallerCount(&self, nums: Vec
) -> Vec
{ // write code here } }
[9,8,7,6,5]
[4,3,2,1,0]
[5,7,8,9,6]
[0,1,1,1,0]