diff --git "a/pictures/plugin/\345\205\250\345\256\266\346\241\266.jpg" "b/pictures/plugin/\345\205\250\345\256\266\346\241\266.jpg" index c556a4d4b9cac304a692c759ef1cd8b1fd981501..b97e4cbb4ba8a75b1a77e6eb102b13020aa51e09 100644 Binary files "a/pictures/plugin/\345\205\250\345\256\266\346\241\266.jpg" and "b/pictures/plugin/\345\205\250\345\256\266\346\241\266.jpg" differ diff --git "a/pictures/\345\205\250\345\256\266\346\241\266.jpg" "b/pictures/\345\205\250\345\256\266\346\241\266.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..b97e4cbb4ba8a75b1a77e6eb102b13020aa51e09 Binary files /dev/null and "b/pictures/\345\205\250\345\256\266\346\241\266.jpg" differ diff --git "a/\346\225\260\346\215\256\347\273\223\346\236\204\347\263\273\345\210\227/\351\230\237\345\210\227\345\256\236\347\216\260\346\240\210\346\240\210\345\256\236\347\216\260\351\230\237\345\210\227.md" "b/\346\225\260\346\215\256\347\273\223\346\236\204\347\263\273\345\210\227/\351\230\237\345\210\227\345\256\236\347\216\260\346\240\210\346\240\210\345\256\236\347\216\260\351\230\237\345\210\227.md" index 81b7b2b71e13b6999ae43f9b76c6e8477dde4c1c..400db3886fb532294a79283b188e620fe1fcc01f 100644 --- "a/\346\225\260\346\215\256\347\273\223\346\236\204\347\263\273\345\210\227/\351\230\237\345\210\227\345\256\236\347\216\260\346\240\210\346\240\210\345\256\236\347\216\260\351\230\237\345\210\227.md" +++ "b/\346\225\260\346\215\256\347\273\223\346\236\204\347\263\273\345\210\227/\351\230\237\345\210\227\345\256\236\347\216\260\346\240\210\346\240\210\345\256\236\347\216\260\351\230\237\345\210\227.md" @@ -20,6 +20,7 @@ | [225. Implement Stack using Queues](https://leetcode.com/problems/implement-stack-using-queues/) | [225. 用队列实现栈](https://leetcode.cn/problems/implement-stack-using-queues/) | 🟢 | [232. Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks/) | [232. 用栈实现队列](https://leetcode.cn/problems/implement-queue-using-stacks/) | 🟢 | - | [剑指 Offer 09. 用两个栈实现队列](https://leetcode.cn/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof/) | 🟢 +| - | [剑指 Offer 09. 用两个栈实现队列](https://leetcode.cn/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof/) | 🟢 **-----------** diff --git "a/\347\256\227\346\263\225\346\200\235\347\273\264\347\263\273\345\210\227/\345\270\270\347\224\250\347\232\204\344\275\215\346\223\215\344\275\234.md" "b/\347\256\227\346\263\225\346\200\235\347\273\264\347\263\273\345\210\227/\345\270\270\347\224\250\347\232\204\344\275\215\346\223\215\344\275\234.md" index 2958d68404fc244d5e0f33b0792fa62a5aac7541..64d064811c24b52fdac3bb93d62099861509ecce 100644 --- "a/\347\256\227\346\263\225\346\200\235\347\273\264\347\263\273\345\210\227/\345\270\270\347\224\250\347\232\204\344\275\215\346\223\215\344\275\234.md" +++ "b/\347\256\227\346\263\225\346\200\235\347\273\264\347\263\273\345\210\227/\345\270\270\347\224\250\347\232\204\344\275\215\346\223\215\344\275\234.md" @@ -27,7 +27,7 @@ 位操作(Bit Manipulation)可以有很多技巧,有一个叫做 Bit Twiddling Hacks 的网站收集了几乎所有位操作的黑科技玩法,网址如下: -http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel +http://graphics.stanford.edu/~seander/bithacks.html 但是这些技巧大部分都过于晦涩,我觉得可以作为字典查阅,没必要逐条深究。但我认为那些有趣的、有用的位运算技巧,是我们每个人需要掌握的。​ @@ -126,6 +126,8 @@ while (true) { // 输出:1,2,3,4,1,2,3,4,1,2,3,4... ``` +> note:注意这个技巧只适用于数组长度是 2 的幂次方的情况,比如 2、4、8、16、32 以此类推。至于如何将数组长度扩展为 2 的幂次方,这也是有比较巧妙的位运算算法的,可以参考 https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 + 简单说,`& (arr.length - 1)` 这个位运算能够替代 `% arr.length` 的模运算,性能会更好一些。 那问题来了,现在是不断地 `index++`,你做到了循环遍历。但如果不断地 `index--`,还能做到环形数组的效果吗?