chefyuan / algorithm-base Goto Github PK
View Code? Open in Web Editor NEW一位酷爱做饭的程序员,立志用动画将算法说的通俗易懂。我的面试网站 www.chengxuchu.com
License: MIT License
一位酷爱做饭的程序员,立志用动画将算法说的通俗易懂。我的面试网站 www.chengxuchu.com
License: MIT License
如题
您在最后一部分写的关于队列是否满了的计算中,(1+1)%5=3 ,这里(1+1)%5应该等于2
Leetcode官方提供了一种用 AND,XOR 和 NOT 的解法。代码如下:
class Solution {
public int singleNumber(int[] nums) {
int seenOnce = 0, seenTwice = 0;
for (int num : nums) {
seenOnce = ~seenTwice & (seenOnce ^ num);
seenTwice = ~seenOnce & (seenTwice ^ num);
}
return seenOnce;
}
}
这个算法设计得很巧妙,只出现一次的数会在 seenOnce 里,出现两次的在 seenTwice 里,速度也比其他的方法快好多。
我才疏学浅,看的有点脑壳疼,希望有哪位大哥大姐可以解释一下,一同加到这个仓库的文章里。谢谢。
然后我们再根据以下公式则能够判断队列满没满了。
(rear+1)%queuesize==front
queuesize,代表队列的长度,上图为5。我们来判断上面两张图是否满。(4+1)%5==0,(1+1)%5==3
两种情况都是满的,over。
在循环队列一节中,最后判断队列是否已满,(1+1)%5==3
的计算结果应为2.
请问有pdf吗?
是否有计划添加Python实现呢。
关于栈和队列的那些事.md 里的
“若是符合则判断其与栈顶符号的优先级”
“符合” 应该是 “符号”
文章很不错,真就是通俗易懂,博主加油!
题主需不需要算法劳动力的
动态规划告急
DP太重要了,其余的都可以放一放,赶紧把DP整了呀
文章中的动图,是用什么软件画的?
点赞!
我不知道是不是我打开方式有问题:我把这个仓库克隆到本地然后用IDEA阅读,发现那些.md文件的内容不是按照顺序来的,比如我想学习“二分查找及其变种”里面的内容,结果发现里面的内容不是按顺序来讲解的,就很麻烦
作者,您好:
希尔排序这里出错了
for (int j = i + increment; j < nums.length; ++j) {
这里的增量 j += increment.
leetcode41缺失的第一个正数, 图挂了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.