Skip to content

Commit 7922d05

Browse files
committed
leetcode
1 parent 4a26804 commit 7922d05

File tree

4 files changed

+306
-8
lines changed

4 files changed

+306
-8
lines changed

leetcode/editor/cn/PowxN.java renamed to leetcode/editor/cn/_0050_PowxN_v1.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828

2929
package leetcode.editor.cn;
3030

31-
public class PowxN {
31+
public class _0050_PowxN_v1 {
3232

3333
public static void main(String[] args) {
34-
Solution solution = new PowxN().new Solution();
34+
Solution solution = new _0050_PowxN_v1().new Solution();
3535
System.out.println(solution.myPow(2, 4));
3636
}
3737

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//实现 pow(x, n) ,即计算 x 的 n 次幂函数。
2+
//
3+
// 示例 1:
4+
//
5+
// 输入: 2.00000, 10
6+
//输出: 1024.00000
7+
//
8+
//
9+
// 示例 2:
10+
//
11+
// 输入: 2.10000, 3
12+
//输出: 9.26100
13+
//
14+
//
15+
// 示例 3:
16+
//
17+
// 输入: 2.00000, -2
18+
//输出: 0.25000
19+
//解释: 2-2 = 1/22 = 1/4 = 0.25
20+
//
21+
// 说明:
22+
//
23+
//
24+
// -100.0 < x < 100.0
25+
// n 是 32 位有符号整数,其数值范围是 [−231, 231 − 1] 。
26+
//
27+
// Related Topics 数学 二分查找
28+
29+
30+
package leetcode.editor.cn;
31+
32+
public class _0050_PowxN_v2 {
33+
34+
public static void main(String[] args) {
35+
Solution solution = new _0050_PowxN_v2().new Solution();
36+
}
37+
38+
//leetcode submit region begin(Prohibit modification and deletion)
39+
class Solution {
40+
41+
public double myPow(double x, int n) {
42+
if (n == 0) return 1;
43+
if (n == 1) return x;
44+
if (n < 0) return 1 / x * myPow(1 / x, -(n + 1));
45+
return n % 2 == 0 ? myPow(x * x, n / 2) : x * myPow(x * x, n / 2);
46+
}
47+
}
48+
//leetcode submit region end(Prohibit modification and deletion)
49+
50+
}

leetcode/editor/cn/all.json

Lines changed: 232 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@
3131
"level": 2,
3232
"nodeType": "def",
3333
"questionId": "3",
34-
"status": "",
34+
"status": "ac",
3535
"title": "无重复字符的最长子串",
3636
"titleSlug": "longest-substring-without-repeating-characters"
3737
},
3838
{
3939
"articleLive": 2,
40-
"formTitle": "[4]寻找两个有序数组的中位数",
40+
"formTitle": "[4]寻找两个正序数组的中位数",
4141
"frontendQuestionId": "4",
4242
"leaf": true,
4343
"level": 3,
4444
"nodeType": "def",
4545
"questionId": "4",
4646
"status": "ac",
47-
"title": "寻找两个有序数组的中位数",
47+
"title": "寻找两个正序数组的中位数",
4848
"titleSlug": "median-of-two-sorted-arrays"
4949
},
5050
{
@@ -6859,7 +6859,7 @@
68596859
"level": 1,
68606860
"nodeType": "def",
68616861
"questionId": "572",
6862-
"status": "",
6862+
"status": "ac",
68636863
"title": "另一个树的子树",
68646864
"titleSlug": "subtree-of-another-tree"
68656865
},
@@ -17099,6 +17099,234 @@
1709917099
"title": "带限制的子序列和",
1710017100
"titleSlug": "constrained-subsequence-sum"
1710117101
},
17102+
{
17103+
"articleLive": 2,
17104+
"formTitle": "[1426]数元素",
17105+
"frontendQuestionId": "1426",
17106+
"leaf": true,
17107+
"level": 1,
17108+
"nodeType": "def",
17109+
"questionId": "1391",
17110+
"status": "",
17111+
"title": "数元素",
17112+
"titleSlug": "counting-elements"
17113+
},
17114+
{
17115+
"articleLive": 2,
17116+
"formTitle": "[1427]Perform String Shifts",
17117+
"frontendQuestionId": "1427",
17118+
"leaf": true,
17119+
"level": 1,
17120+
"nodeType": "def",
17121+
"questionId": "1345",
17122+
"status": "",
17123+
"title": "Perform String Shifts",
17124+
"titleSlug": "perform-string-shifts"
17125+
},
17126+
{
17127+
"articleLive": 2,
17128+
"formTitle": "[1428]Leftmost Column with at Least a One",
17129+
"frontendQuestionId": "1428",
17130+
"leaf": true,
17131+
"level": 2,
17132+
"nodeType": "def",
17133+
"questionId": "1374",
17134+
"status": "",
17135+
"title": "Leftmost Column with at Least a One",
17136+
"titleSlug": "leftmost-column-with-at-least-a-one"
17137+
},
17138+
{
17139+
"articleLive": 2,
17140+
"formTitle": "[1429]First Unique Number",
17141+
"frontendQuestionId": "1429",
17142+
"leaf": true,
17143+
"level": 2,
17144+
"nodeType": "def",
17145+
"questionId": "1366",
17146+
"status": "",
17147+
"title": "First Unique Number",
17148+
"titleSlug": "first-unique-number"
17149+
},
17150+
{
17151+
"articleLive": 2,
17152+
"formTitle": "[1430]Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree",
17153+
"frontendQuestionId": "1430",
17154+
"leaf": true,
17155+
"level": 2,
17156+
"nodeType": "def",
17157+
"questionId": "1432",
17158+
"status": "",
17159+
"title": "Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree",
17160+
"titleSlug": "check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree"
17161+
},
17162+
{
17163+
"articleLive": 2,
17164+
"formTitle": "[1431]拥有最多糖果的孩子",
17165+
"frontendQuestionId": "1431",
17166+
"leaf": true,
17167+
"level": 1,
17168+
"nodeType": "def",
17169+
"questionId": "1528",
17170+
"status": "",
17171+
"title": "拥有最多糖果的孩子",
17172+
"titleSlug": "kids-with-the-greatest-number-of-candies"
17173+
},
17174+
{
17175+
"articleLive": 2,
17176+
"formTitle": "[1432]改变一个整数能得到的最大差值",
17177+
"frontendQuestionId": "1432",
17178+
"leaf": true,
17179+
"level": 2,
17180+
"nodeType": "def",
17181+
"questionId": "1529",
17182+
"status": "",
17183+
"title": "改变一个整数能得到的最大差值",
17184+
"titleSlug": "max-difference-you-can-get-from-changing-an-integer"
17185+
},
17186+
{
17187+
"articleLive": 2,
17188+
"formTitle": "[1433]检查一个字符串是否可以打破另一个字符串",
17189+
"frontendQuestionId": "1433",
17190+
"leaf": true,
17191+
"level": 2,
17192+
"nodeType": "def",
17193+
"questionId": "1530",
17194+
"status": "",
17195+
"title": "检查一个字符串是否可以打破另一个字符串",
17196+
"titleSlug": "check-if-a-string-can-break-another-string"
17197+
},
17198+
{
17199+
"articleLive": 2,
17200+
"formTitle": "[1434]每个人戴不同帽子的方案数",
17201+
"frontendQuestionId": "1434",
17202+
"leaf": true,
17203+
"level": 3,
17204+
"nodeType": "def",
17205+
"questionId": "1531",
17206+
"status": "",
17207+
"title": "每个人戴不同帽子的方案数",
17208+
"titleSlug": "number-of-ways-to-wear-different-hats-to-each-other"
17209+
},
17210+
{
17211+
"articleLive": 2,
17212+
"formTitle": "[1435]Create a Session Bar Chart",
17213+
"frontendQuestionId": "1435",
17214+
"leaf": true,
17215+
"level": 1,
17216+
"nodeType": "def",
17217+
"questionId": "1564",
17218+
"status": "",
17219+
"title": "Create a Session Bar Chart",
17220+
"titleSlug": "create-a-session-bar-chart"
17221+
},
17222+
{
17223+
"articleLive": 2,
17224+
"formTitle": "[1436]旅行终点站",
17225+
"frontendQuestionId": "1436",
17226+
"leaf": true,
17227+
"level": 1,
17228+
"nodeType": "def",
17229+
"questionId": "1547",
17230+
"status": "ac",
17231+
"title": "旅行终点站",
17232+
"titleSlug": "destination-city"
17233+
},
17234+
{
17235+
"articleLive": 2,
17236+
"formTitle": "[1437]是否所有 1 都至少相隔 k 个元素",
17237+
"frontendQuestionId": "1437",
17238+
"leaf": true,
17239+
"level": 2,
17240+
"nodeType": "def",
17241+
"questionId": "1548",
17242+
"status": "ac",
17243+
"title": "是否所有 1 都至少相隔 k 个元素",
17244+
"titleSlug": "check-if-all-1s-are-at-least-length-k-places-away"
17245+
},
17246+
{
17247+
"articleLive": 2,
17248+
"formTitle": "[1438]绝对差不超过限制的最长连续子数组",
17249+
"frontendQuestionId": "1438",
17250+
"leaf": true,
17251+
"level": 2,
17252+
"nodeType": "def",
17253+
"questionId": "1549",
17254+
"status": "",
17255+
"title": "绝对差不超过限制的最长连续子数组",
17256+
"titleSlug": "longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit"
17257+
},
17258+
{
17259+
"articleLive": 2,
17260+
"formTitle": "[1439]有序矩阵中的第 k 个最小数组和",
17261+
"frontendQuestionId": "1439",
17262+
"leaf": true,
17263+
"level": 3,
17264+
"nodeType": "def",
17265+
"questionId": "1550",
17266+
"status": "",
17267+
"title": "有序矩阵中的第 k 个最小数组和",
17268+
"titleSlug": "find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows"
17269+
},
17270+
{
17271+
"articleLive": 2,
17272+
"formTitle": "[1440]Evaluate Boolean Expression",
17273+
"frontendQuestionId": "1440",
17274+
"leaf": true,
17275+
"level": 2,
17276+
"nodeType": "def",
17277+
"questionId": "1565",
17278+
"status": "",
17279+
"title": "Evaluate Boolean Expression",
17280+
"titleSlug": "evaluate-boolean-expression"
17281+
},
17282+
{
17283+
"articleLive": 2,
17284+
"formTitle": "[1441]用栈操作构建数组",
17285+
"frontendQuestionId": "1441",
17286+
"leaf": true,
17287+
"level": 1,
17288+
"nodeType": "def",
17289+
"questionId": "1552",
17290+
"status": "ac",
17291+
"title": "用栈操作构建数组",
17292+
"titleSlug": "build-an-array-with-stack-operations"
17293+
},
17294+
{
17295+
"articleLive": 2,
17296+
"formTitle": "[1442]形成两个异或相等数组的三元组数目",
17297+
"frontendQuestionId": "1442",
17298+
"leaf": true,
17299+
"level": 2,
17300+
"nodeType": "def",
17301+
"questionId": "1553",
17302+
"status": "ac",
17303+
"title": "形成两个异或相等数组的三元组数目",
17304+
"titleSlug": "count-triplets-that-can-form-two-arrays-of-equal-xor"
17305+
},
17306+
{
17307+
"articleLive": 2,
17308+
"formTitle": "[1443]收集树上所有苹果的最少时间",
17309+
"frontendQuestionId": "1443",
17310+
"leaf": true,
17311+
"level": 2,
17312+
"nodeType": "def",
17313+
"questionId": "1554",
17314+
"status": "ac",
17315+
"title": "收集树上所有苹果的最少时间",
17316+
"titleSlug": "minimum-time-to-collect-all-apples-in-a-tree"
17317+
},
17318+
{
17319+
"articleLive": 2,
17320+
"formTitle": "[1444]切披萨的方案数",
17321+
"frontendQuestionId": "1444",
17322+
"leaf": true,
17323+
"level": 3,
17324+
"nodeType": "def",
17325+
"questionId": "1555",
17326+
"status": "",
17327+
"title": "切披萨的方案数",
17328+
"titleSlug": "number-of-ways-of-cutting-a-pizza"
17329+
},
1710217330
{
1710317331
"articleLive": 2,
1710417332
"formTitle": "[LCP 01]猜数字",

leetcode/editor/cn/translation.json

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
{
2020
"questionId": "4",
21-
"title": "\u5bfb\u627e\u4e24\u4e2a\u6709\u5e8f\u6570\u7ec4\u7684\u4e2d\u4f4d\u6570",
21+
"title": "\u5bfb\u627e\u4e24\u4e2a\u6b63\u5e8f\u6570\u7ec4\u7684\u4e2d\u4f4d\u6570",
2222
"__typename": "AppliedTranslationNode"
2323
},
2424
{
@@ -7153,7 +7153,7 @@
71537153
},
71547154
{
71557155
"questionId": "1548",
7156-
"title": "\u81f3\u5c11\u76f8\u9694 k \u4e2a\u5143\u7d20",
7156+
"title": "\u662f\u5426\u6240\u6709 1 \u90fd\u81f3\u5c11\u76f8\u9694 k \u4e2a\u5143\u7d20",
71577157
"__typename": "AppliedTranslationNode"
71587158
},
71597159
{
@@ -7166,6 +7166,26 @@
71667166
"title": "\u6709\u5e8f\u77e9\u9635\u4e2d\u7684\u7b2c k \u4e2a\u6700\u5c0f\u6570\u7ec4\u548c",
71677167
"__typename": "AppliedTranslationNode"
71687168
},
7169+
{
7170+
"questionId": "1552",
7171+
"title": "\u7528\u6808\u64cd\u4f5c\u6784\u5efa\u6570\u7ec4",
7172+
"__typename": "AppliedTranslationNode"
7173+
},
7174+
{
7175+
"questionId": "1553",
7176+
"title": "\u5f62\u6210\u4e24\u4e2a\u5f02\u6216\u76f8\u7b49\u6570\u7ec4\u7684\u4e09\u5143\u7ec4\u6570\u76ee",
7177+
"__typename": "AppliedTranslationNode"
7178+
},
7179+
{
7180+
"questionId": "1554",
7181+
"title": "\u6536\u96c6\u6811\u4e0a\u6240\u6709\u82f9\u679c\u7684\u6700\u5c11\u65f6\u95f4",
7182+
"__typename": "AppliedTranslationNode"
7183+
},
7184+
{
7185+
"questionId": "1555",
7186+
"title": "\u5207\u62ab\u8428\u7684\u65b9\u6848\u6570",
7187+
"__typename": "AppliedTranslationNode"
7188+
},
71697189
{
71707190
"questionId": "100002",
71717191
"title": "2019 \u5e74\u4e0a\u6d77\u5e02\u521b\u610f\u7f16\u7a0b\u4e0e\u667a\u80fd\u8bbe\u8ba1\u5927\u8d5b \u7b97\u6cd5\u7f16\u7a0b \u5c0f\u5b66\u7ec4 \u521d\u8d5b\u7b2c\u4e00\u9898",

0 commit comments

Comments
 (0)