当前位置:网站首页>Leetcode 1523. count odd numbers within the interval
Leetcode 1523. count odd numbers within the interval
2022-07-26 13:11:00 【PUdd】
LeetCode 1523. Count the odd number in the interval
Their thinking
| low | high | Number |
|---|---|---|
| accidentally | accidentally | (high-low+0)/2 |
| p. | p. | (high-low+2)/2 |
| accidentally | p. | (high-low+1)/2 |
| p. | accidentally | (high-low+1)/2 |
C++ Code
class Solution
{
public:
int countOdds(int low, int high)
{
return (high-low+low%2+high%2)/2;
}
};
边栏推荐
- Redis realizes single sign on -- system framework construction (I)
- Flutter integrated Aurora push
- Kubernetes flannel: host-gw mode
- 二叉树的初阶笔记
- 历史上的今天:IBM 获得了第一项专利;Verizon 收购雅虎;亚马逊发布 Fire Phone...
- Ue5 official case Lyra full feature explanation 7. resource management
- 【花雕动手做】有趣好玩的音乐可视化系列小项目(12)---米管快速节奏灯
- 牛客刷SQL---2
- (int argc, char** argv) command line parameters in visual stdio (VS)
- 概要设计说明书
猜你喜欢

Sword finger offer 24. reverse the linked list

基于C#实现的学生考试系统

Solution: unable to load the file c:\users\user\appdata\roaming\npm\npx PS1, because running scripts is prohibited on this system.
![[typescript] typescript common types (Part 2)](/img/6b/2ac07f16af044bdfb719753ae241cc.png)
[typescript] typescript common types (Part 2)

C regards type as generic type T and uses it as generic type of method

基于WebRTC和WebSocket实现的聊天系统

Version of NDK matched the requested version 21.0.6113669. versions available locally: 2

基于ASP.NET的某高校学院档案管理系统

最好的工程师,就是这样被你“逼”走的!

Food safety | can you eat any fruit?
随机推荐
Interviewer: how to understand QPS, TPS, RT?
0 basic programming resources (collect first ~ read slowly ~)
Extra(5)—mysql执行计划(五十一)
Sword finger offer (21): push in and pop-up sequence of stack
Mysql数据目录(2)---表数据结构(二十五)
Kubernetes APIServer 限流策略
Kubernetes flannel: host-gw mode
B+树索引使用(9)分组、回表、覆盖索引(二十一)
B+树(5)myISAM简介 --mysql从入门到精通(十七)
Use grid to realize left, middle and right layout, and the middle content is adaptive
How to optimize a large number of if else [email protected] Detailed explanation of valib
3D modeling and rendering based on B é zier curve
子组件触发父组件自定义事件(defineEmits):子组件传值给父组件
Kubernetes Flannel:HOST-GW模式
Kubernetes apiserver current limiting strategy
postgresql官网下载出错
Kubernetes----安装部署NFS服务器
Redis realizes single sign on -- system framework construction (I)
(int argc, char** argv) command line parameters in visual stdio (VS)
Code examples explain the difference between [reentrant lock] and [non reentrant lock]?