problem

1089. Duplicate Zeros

题意:

solution: 其中关于虚拟新数组的下标的计算还是有点迷糊。。。

class Solution {
public:
void duplicateZeros(vector<int>& arr) {
int n = arr.size();
int m = n + count(arr.begin(), arr.end(), );
for(int i=n-; i>=; i--)
{
if((--m) <n) //err....
{
arr[m] = arr[i];
} if(arr[i]== && (--m) <n) //errr...
{
arr[m] = ;
}
}
}
};

参考

1. Leetcode_easy_1089. Duplicate Zeros;

2. discuss;

【Leetcode_easy】1089. Duplicate Zeros的更多相关文章

  1. 【leetcode】1089. Duplicate Zeros

    题目如下: Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the re ...

  2. 【原创】<Debug> “duplicate connection name”

    [Problem] duplicate connection name [Solution] 在Qt上使用SQLite的时候,如果第二次使用QSqlDatabase::addDatabase()方式时 ...

  3. 【51NOD-0】1089 最长回文子串 V2(Manacher算法)

    [算法]回文树 #include<cstdio> #include<algorithm> #include<cstring> using namespace std ...

  4. 【axc】关于duplicate symbols for architecture x86_64错误的第三种可能及其解决办法

    今天分析一下duplicate symbols for architecture x86_64错误  也是困扰我一段时间   不过很幸运 在半个小时内找到了解决方案 百度上对于duplicate sy ...

  5. 【转】XCode: duplicate symbol 解决方案

    遇到引用库重复定义的问题,需要解决. 项目需要,同时引用ZBar和QQ授权登录SDK,由于二者均使用了Base64处理数据,XCode编译时报错: duplicate symbol _base64_e ...

  6. 【BZOJ】1089: [SCOI2003]严格n元树(递推+高精度/fft)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1089 题意:求深度为d的n元树数目.(0<n<=32, 0<=d<=16) ...

  7. 【leetcode】Contains Duplicate & Rectangle Area(easy)

    Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your funct ...

  8. leetcode【sql】 Delete Duplicate Emails

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  9. 【SQL】182. Duplicate Emails

    Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...

随机推荐

  1. 是什么是FBC CBV

    - FBV url   -   函数 - CBV url   -   view

  2. DOM设置css样式

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  3. 55、servlet3.0-ServletContext注册三大组件

    55.servlet3.0-ServletContext注册三大组件 使用ServletContext 注册 Servlet.Filter.Listener 使用编码的方式,在项目启动的时候给 Ser ...

  4. vue中$refs、,$emit、$on

    $emit https://blog.csdn.net/sllailcp/article/details/78595077 $on https://www.jianshu.com/p/a544728b ...

  5. Educational Codeforces Round 60 D. Magic Gems

    易得递推式为f[i]=f[i-1]+f[i-M] 最终答案即为f[N]. 由于N很大,用矩阵快速幂求解. code: #include<bits/stdc++.h> using names ...

  6. LibreOJ #6. Guess Number

    二次联通门 : LibreOJ #6. Guess Number /* LibreOJ #6. Guess Number 交互题初体验 用了二分判定 感觉不错 */ #include "in ...

  7. 【概率论】4-7:条件期望(Conditional Expectation)

    title: [概率论]4-7:条件期望(Conditional Expectation) categories: - Mathematic - Probability keywords: - Exp ...

  8. CSPS模拟88-91

    感觉自己好菜啊,考得一次不如一次了...压力好大,++滚粗感. 模拟88. T1,sbt,发现离散化后数据范围变为6000,直接跑暴力即可.%%%机房众神斜率优化. T2,大模拟,考场上只会乱搞骗分. ...

  9. python qq发消息

    # 原理是先将需要发送的文本放到剪贴板中,然后将剪贴板内容发送到qq窗口 # 之后模拟按键发送enter键发送消息 import win32gui import win32con import win ...

  10. 视觉SLAM十四讲(三)——三维空间刚体运动(下)

    理论部分请看 :三维空间刚体运动 一.Eigen的使用 首先安装 Eigen: sudo apt-get install libeigen3-dev 一般都安装在 /usr/include/eigen ...