算法 思路
文章平均质量分 88
a88268746
这个作者很懒,什么都没留下…
展开
-
伪码记录一些重要算法的思路(持续整理)
基于内容精简、重点突出、便于理解的这些优点,选择中文伪码来记录。一般地,left、right分别表示待操作数组的起止索引,或是链表的头尾指针。_______________________________________________ 二分查找当数组有元素时(left<=right)循环: ...2015-07-09 09:02:02 · 361 阅读 · 0 评论 -
leetCode周赛102解题报告 javascript
比赛地址:https://lingkou.com/contest/weekly-contest-102 905. 按奇偶校验排序数组905. Sort Array By Parity给定一个非负整数数组 A,返回一个由 A 的所有偶数元素组成的数组,后面跟 A 的所有奇数元素。你可以返回满足此条件的任何数组作为答案。 示例:输入:[3,1,2,4]输出:[...2018-09-18 16:42:59 · 180 阅读 · 0 评论 -
leetCode周赛100解题报告 javascript
比赛地址:https://leetcode-cn.com/contest/weekly-contest-100 896. 单调数列896. Monotonic Array如果数组是单调递增或单调递减的,那么它是单调的。如果对于所有 i <= j,A[i] <= A[j],那么数组 A 是单调递增的。 如果对于所有 i <= j,A[i]> = A[...2018-09-02 11:37:09 · 206 阅读 · 0 评论 -
leetCode周赛98解题报告 javascript
比赛地址:https://leetcode-cn.com/contest/weekly-contest-98 888. 公平的糖果交换888. Fair Candy Swap爱丽丝和鲍勃有不同大小的糖果棒:A[i] 是爱丽丝拥有的第 i 块糖的大小,B[j] 是鲍勃拥有的第 j 块糖的大小。因为他们是朋友,所以他们想交换一个糖果棒,这样交换后,他们都有相同的糖果总量。(...2018-08-19 12:45:41 · 162 阅读 · 0 评论 -
leetCode周赛97解题报告 javascript
比赛地址:https://leetcode-cn.com/contest/weekly-contest-97 888. 两句话中的不常见单词888. Uncommon Words from Two Sentences给定两个句子 A 和 B 。 (句子是一串由空格分隔的单词。每个单词仅由小写字母组成。)如果一个单词在其中一个句子中只出现一次,在另一个句子中却没有出现,那么...2018-08-12 14:04:08 · 217 阅读 · 0 评论 -
leetCode周赛96解题报告 javascript
比赛地址:https://leetcode-cn.com/contest/weekly-contest-96 887. Projection Area of 3D Shapes887. 三维形体投影面积在 N * N 的网格中,我们放置了一些与 x,y,z 三轴对齐的 1 * 1 * 1 立方体。每个值 v = grid[i][j] 表示 v 个正方体叠放在单元格 (i,...2018-08-05 12:25:50 · 135 阅读 · 0 评论 -
leetCode周赛95解题报告 javascript
比赛地址https://leetcode-cn.com/contest/weekly-contest-95 876. Middle of the Linked List876. 链表的中间结点给定一个带有头结点 head 的非空单链表,返回链表的中间结点。如果有两个中间结点,则返回第二个中间结点。 示例 1:输入:[1,2,3,4,5]输出:此列表中的结...2018-07-29 12:18:09 · 155 阅读 · 0 评论 -
leetCode周赛94解题报告 javascript
比赛地址https://leetcode-cn.com/contest/weekly-contest-94 872. Leaf-Similar Trees考虑一个二叉树的所有叶子。这些叶子的值按从左到右的顺序排列形成一个 叶值序列 。举个例子,给定一个如上图所示的树,其叶值序列为 (6, 7, 4, 9, 8) 。如果两个二叉树的叶值序列相同,我们就认为它们是 叶相...2018-07-22 11:26:12 · 195 阅读 · 0 评论 -
leetCode周赛93解题报告 javascript
比赛地址https://leetcode-cn.com/contest/weekly-contest-93 868. 二进制间距给定一个正整数 N,找到并返回 N 的二进制表示中两个连续的 1 之间的最长距离。 如果没有两个连续的 1,返回 0 。 示例 1:输入:22输出:2解释:22 的二进制是 0b10110 。在 22 的二进制表示中,有三...2018-07-15 12:51:09 · 237 阅读 · 0 评论 -
leetCode周赛89解题报告 javascript
比赛地址https://leetcode.com/contest/weekly-contest-89 852. Peak Index in a Mountain Array我们把符合下列属性的数组 A 称作山脉:A.length >= 3存在 0 < i < A.length - 1 使得A[0] < A[1] < ... A[i-1]...2018-06-17 12:08:51 · 150 阅读 · 0 评论 -
leetCode周赛83 JavaScript解题报告829.Consecutive Numbers Sum 828.Unique Letter String
比赛地址https://leetcode.com/contest/weekly-contest-83 830. Positions of Large GroupsIn a string S of lowercase letters, these letters form consecutive groups of the same character.For example, a...原创 2018-05-06 11:15:23 · 297 阅读 · 0 评论 -
leetCode周赛82解题报告 JavaScript
比赛地址https://leetcode.com/contest/weekly-contest-82 824. Goat LatinA sentence S is given, composed of words separated by spaces. Each word consists of lowercase and uppercase letters only....2018-04-29 12:11:52 · 191 阅读 · 0 评论 -
leetCode周赛81解题报告
比赛地址https://leetcode.com/contest/weekly-contest-81 821. Shortest Distance to a CharacterGiven a string S and a character C, return an array of integers representing the shortest distance from ...2018-04-22 11:13:47 · 255 阅读 · 0 评论 -
leetCode周赛106解题报告 javascript
比赛地址:https://leetcode-cn.com/contest/weekly-contest-106922. 按奇偶排序数组 II922. Sort Array By Parity II给定一个非负整数数组 A, A 中一半整数是奇数,一半整数是偶数。对数组进行排序,以便当 A[i] 为奇数时,i 也是奇数;当 A[i] 为偶数时, i 也是偶数。你可以返回任何...2018-10-15 19:07:27 · 225 阅读 · 0 评论