zjuturtle's recent timeline updates
zjuturtle

zjuturtle

V2EX member #245065, joined on 2017-07-28 09:39:23 +08:00
zjuturtle's recent replies
Dec 10, 2023
Replied to a topic by shaoshuang 宽带症候群 杭州电信 2000M 宽带办理踩坑记录
我也是余杭,一波投诉 299/月给了 1000/100.没有上行叠加包。实测大约 1100 上行/140 下行
去亚马逊海淘个 LG UltraFine 4K 翻新版本吧
Apr 13, 2018
Replied to a topic by letianqiu 程序员 一道 FFT 相关的题
可以参考一下我的博客
https://zjuturtle.com/2017/12/26/fft/
Feb 22, 2018
Replied to a topic by harry890829 Apple 20 号在苹果官网定制了 macbook pro
其实你在苹果官网上买贵了 15%是有的,去麦克先生不好么
我有点后悔没买俩 5K
Feb 19, 2018
Replied to a topic by greenhat233 问与答 一道简单的 c++编程题求解答
@zjuturtle 日原题有很多变种我特么又贴错了,给跪。
原题
https://leetcode.com/problems/single-number/description/
解答
#include<iostream>
#include<vector>

using namespace std;
class Solution {
public:
int singleNumber(vector<int>& nums) {
int res = 0;
for (auto it = nums.begin(); it != nums.end(); it++) {
res ^= *it;
}
return res;
}
};
Feb 19, 2018
Replied to a topic by greenhat233 问与答 一道简单的 c++编程题求解答
@zjuturtle 日贴错了,应该是这个

#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
int singleNumber(vector<int>& nums) {
vector<int> positiveCounts(32, 0);
vector<int> negtiveCounts(32, 0);
for (auto it = nums.begin(); it != nums.end(); it++) {
auto tmp = *it;
int index = 0;
if (tmp > 0) {
while (tmp!=0) {
positiveCounts[index] += (tmp % 2);
tmp /= 2;
index++;
}
}
else {
tmp = -tmp;
while (tmp != 0) {
negtiveCounts[index] += (tmp % 2);
tmp /= 2;
index++;
}
}
}
int pos = 0,neg=0,p=1,n=1;
for (int i = 0; i < 32; i++) {
auto pbit = positiveCounts[i] %= 3;
auto nbit = negtiveCounts[i] %= 3;
pos += (pbit*p);
neg += (nbit*n);
p *= 2;
n *= 2;
}
if(pos>0)
return pos;
return -neg;
}
};
Feb 19, 2018
Replied to a topic by greenhat233 问与答 一道简单的 c++编程题求解答
leetcode 上有这道题目
https://leetcode.com/problems/single-number-ii/description/
时间复杂度 O(n)
空间复杂度 O(1)

using namespace std;
class Solution {
public:
vector<int> singleNumber(vector<int>& nums) {
int tmp=0,tmp1=1,numA=0,numB=0;
for (auto it = nums.begin(); it != nums.end(); it++) {
tmp ^= (*it);
}
while (tmp % 2 == 0) {
tmp1 *= 2;
tmp /= 2;
}

for (auto it = nums.begin(); it != nums.end(); it++) {
if ((tmp1 ^ (*it)) == ((*it)-tmp1)) {
numA ^= (*it);
}
else {
numB ^= (*it);
}
}
auto res = new vector<int>;
(*res).push_back(numA);
(*res).push_back(numB);
return *res;
}
};
Feb 19, 2018
Replied to a topic by AxtonYao 分享创造 新年换新个人页
现在的年轻人都这么屌了啊。。。
Feb 18, 2018
Replied to a topic by cgcs 问与答 有人买过 Coursera 的企业版吗?
Business 完全没意义啊。我现在个人自己学,基本上只要申请奖学金都能给通过。惟二比较麻烦的是审核需要 15 天,专项课程的每一个小课程都要单独申请
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4240 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 400ms · UTC 10:12 · PVG 18:12 · LAX 03:12 · JFK 06:12
♥ Do have faith in what you're doing.