/* * @lc app=leetcode.cn id=169 lang=c * * [169] 求众数 * * https://leetcode-cn.com/problems/majority-element/description/ * * algorithms * Easy (58.05%) * Total Accepted: 27.2K * Total Submissions: 46.7K * Testcase Example: '[3,2,3]' * * 给定一个大小为 n 的数组,…
开学后忙的焦头烂额(懒得很),正式开始刷leecode的题目了. 想了想c语言是最最基础的语言,虽然有很多其他语言很简单,有更多的函数可以用,但c语言能煅炼下自己的思考能力.python则是最流行的语言. 做题用的是 xcode的 leecode插件 非常的方便.顺序从简单到难.开始. [1] 两数之和 * * https://leetcode-cn.com/problems/two-sum/description/ * * algorithms * Easy (44.20%) * Total…
/* * @lc app=leetcode.cn id=387 lang=c * * [387] 字符串中的第一个唯一字符 * * https://leetcode-cn.com/problems/first-unique-character-in-a-string/description/ * * algorithms * Easy (36.55%) * Total Accepted: 23.7K * Total Submissions: 64.7K * Testcase Example: '…
/* * @lc app=leetcode.cn id=28 lang=c * * [28] 实现strStr() * * https://leetcode-cn.com/problems/implement-strstr/description/ * * algorithms * Easy (37.86%) * Total Accepted: 38.6K * Total Submissions: 102K * Testcase Example: '"hello"\n"ll&…
/* * @lc app=leetcode.cn id=7 lang=c * * [7] 整数反转 * * https://leetcode-cn.com/problems/reverse-integer/description/ * * algorithms * Easy (31.36%) * Total Accepted: 77.7K * Total Submissions: 247.8K * Testcase Example: '123' * * 给出一个 32 位的有符号整数,你需要将这…
/* * @lc app=leetcode.cn id=434 lang=c * * [434] 字符串中的单词数 * * https://leetcode-cn.com/problems/number-of-segments-in-a-string/description/ * * algorithms * Easy (29.13%) * Total Accepted: 4.2K * Total Submissions: 14.2K * Testcase Example: '"Hello, m…
/* * @lc app=leetcode.cn id=326 lang=c * * [326] 3的幂 * * https://leetcode-cn.com/problems/power-of-three/description/ * * algorithms * Easy (42.85%) * Total Accepted: 14.2K * Total Submissions: 33.1K * Testcase Example: '27' * * 给定一个整数,写一个函数来判断它是否是 3…
/* * @lc app=leetcode.cn id=263 lang=c * * [263] 丑数 * * https://leetcode-cn.com/problems/ugly-number/description/ * * algorithms * Easy (44.82%) * Total Accepted: 7K * Total Submissions: 15.7K * Testcase Example: '6' * * 编写一个程序判断给定的数是否为丑数. * * 丑数就是只包…
/* * @lc app=leetcode.cn id=383 lang=c * * [383] 赎金信 * * https://leetcode-cn.com/problems/ransom-note/description/ * * algorithms * Easy (44.98%) * Total Accepted: 5K * Total Submissions: 11.1K * Testcase Example: '"a"\n"b"' * * 给定一个赎金…
/* * @lc app=leetcode.cn id=371 lang=c * * [371] 两整数之和 * * https://leetcode-cn.com/problems/sum-of-two-integers/description/ * * algorithms * Easy (55.04%) * Total Accepted: 8.1K * Total Submissions: 14.8K * Testcase Example: '1\n2' * * 不使用运算符 + 和 - …
/* * @lc app=leetcode.cn id=349 lang=c * * [349] 两个数组的交集 * * https://leetcode-cn.com/problems/intersection-of-two-arrays/description/ * * algorithms * Easy (60.49%) * Total Accepted: 15.1K * Total Submissions: 25K * Testcase Example: '[1,2,2,1]\n[2,2…
/* * @lc app=leetcode.cn id=344 lang=c * * [344] 反转字符串 * * https://leetcode-cn.com/problems/reverse-string/description/ * * algorithms * Easy (65.20%) * Total Accepted: 39.8K * Total Submissions: 61.1K * Testcase Example: '["h","e",&qu…
/* * @lc app=leetcode.cn id=217 lang=c * * [217] 存在重复元素 * * https://leetcode-cn.com/problems/contains-duplicate/description/ * * algorithms * Easy (47.25%) * Total Accepted: 46K * Total Submissions: 97.2K * Testcase Example: '[1,2,3,1]' * * 给定一个整数数组,…
/* * @lc app=leetcode.cn id=206 lang=c * * [206] 反转链表 * * https://leetcode-cn.com/problems/reverse-linked-list/description/ * * algorithms * Easy (58.89%) * Total Accepted: 41.2K * Total Submissions: 69.9K * Testcase Example: '[1,2,3,4,5]' * * 反转一个单链…
/* * @lc app=leetcode.cn id=204 lang=c * * [204] 计数质数 * * https://leetcode-cn.com/problems/count-primes/description/ * * algorithms * Easy (26.72%) * Total Accepted: 13.8K * Total Submissions: 51.6K * Testcase Example: '10' * * 统计所有小于非负整数 n 的质数的数量. *…
/* * @lc app=leetcode.cn id=203 lang=c * * [203] 移除链表元素 * * https://leetcode-cn.com/problems/remove-linked-list-elements/description/ * * algorithms * Easy (39.58%) * Total Accepted: 18.3K * Total Submissions: 46.2K * Testcase Example: '[1,2,6,3,4,5,…
/* * @lc app=leetcode.cn id=202 lang=c * * [202] 快乐数 * * https://leetcode-cn.com/problems/happy-number/description/ * * algorithms * Easy (52.26%) * Total Accepted: 12.9K * Total Submissions: 24.7K * Testcase Example: '19' * * 编写一个算法来判断一个数是不是“快乐数”. *…
/* * @lc app=leetcode.cn id=141 lang=c * * [141] 环形链表 * * https://leetcode-cn.com/problems/linked-list-cycle/description/ * * algorithms * Easy (35.53%) * Total Accepted: 28.4K * Total Submissions: 79.4K * Testcase Example: '[3,2,0,-4]\n1' * * 给定一个链表…
/* * @lc app=leetcode.cn id=121 lang=c * * [121] 买卖股票的最佳时机 * * https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/description/ * * algorithms * Easy (48.50%) * Total Accepted: 32.5K * Total Submissions: 66.9K * Testcase Example: '[7,1,5…
/* * @lc app=leetcode.cn id=118 lang=c * * [118] 杨辉三角 * * https://leetcode-cn.com/problems/pascals-triangle/description/ * * algorithms * Easy (60.22%) * Total Accepted: 17.6K * Total Submissions: 29.2K * Testcase Example: '5' * * 给定一个非负整数 numRows,生成…
/* * @lc app=leetcode.cn id=111 lang=c * * [111] 二叉树的最小深度 * * https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/description/ * * algorithms * Easy (37.27%) * Total Accepted: 12.2K * Total Submissions: 32.6K * Testcase Example: '[3,9,20,nu…
/* * @lc app=leetcode.cn id=104 lang=c * * [104] 二叉树的最大深度 * * https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/description/ * * algorithms * Easy (67.34%) * Total Accepted: 33.2K * Total Submissions: 49.2K * Testcase Example: '[3,9,20,nu…
/* * @lc app=leetcode.cn id=101 lang=c * * [101] 对称二叉树 * * https://leetcode-cn.com/problems/symmetric-tree/description/ * * algorithms * Easy (45.30%) * Total Accepted: 23.8K * Total Submissions: 52.4K * Testcase Example: '[1,2,2,3,4,4,3]' * * 给定一个二叉…
/* * @lc app=leetcode.cn id=100 lang=c * * [100] 相同的树 * * https://leetcode-cn.com/problems/same-tree/description/ * * algorithms * Easy (51.47%) * Total Accepted: 16K * Total Submissions: 31K * Testcase Example: '[1,2,3]\n[1,2,3]' * * 给定两个二叉树,编写一个函数来…
/* * @lc app=leetcode.cn id=88 lang=c * * [88] 合并两个有序数组 * * https://leetcode-cn.com/problems/merge-sorted-array/description/ * * algorithms * Easy (43.05%) * Total Accepted: 31.4K * Total Submissions: 73K * Testcase Example: '[1,2,3,0,0,0]\n3\n[2,5,6…
/* * @lc app=leetcode.cn id=83 lang=c * * [83] 删除排序链表中的重复元素 * * https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/description/ * * algorithms * Easy (44.24%) * Total Accepted: 18.4K * Total Submissions: 41.5K * Testcase Example: '[1…
/* * @lc app=leetcode.cn id=70 lang=c * * [70] 爬楼梯 * * https://leetcode-cn.com/problems/climbing-stairs/description/ * * algorithms * Easy (44.44%) * Total Accepted: 33.5K * Total Submissions: 75.4K * Testcase Example: '2' * * 假设你正在爬楼梯.需要 n 阶你才能到达楼顶.…
/* * @lc app=leetcode.cn id=67 lang=c * * [67] 二进制求和 * * https://leetcode-cn.com/problems/add-binary/description/ * * algorithms * Easy (46.67%) * Total Accepted: 17.6K * Total Submissions: 37.8K * Testcase Example: '"11"\n"1"' * * 给定两…
/* * @lc app=leetcode.cn id=69 lang=c * * [69] x 的平方根 * * https://leetcode-cn.com/problems/sqrtx/description/ * * algorithms * Easy (34.81%) * Total Accepted: 25.4K * Total Submissions: 73.1K * Testcase Example: '4' * * 实现 int sqrt(int x) 函数. * * 计算并…
/* * @lc app=leetcode.cn id=66 lang=c * * [66] 加一 * * https://leetcode-cn.com/problems/plus-one/description/ * * algorithms * Easy (37.65%) * Total Accepted: 39.4K * Total Submissions: 104.7K * Testcase Example: '[1,2,3]' * * 给定一个由整数组成的非空数组所表示的非负整数,在…