Skip to content

Commit f4e7121

Browse files
committed
2023-02-08 update: added "69. Sqrt(x)"
1 parent 2a7a880 commit f4e7121

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
2525
| 58. Length of Last Word | [Link](https://leetcode.com/problems/length-of-last-word/) | [Link](./lib/easy/length_of_last_word.dart) |
2626
| 66. Plus One | [Link](https://leetcode.com/problems/plus-one/) | [Link](./lib/easy/plus_one.dart) |
2727
| 67. Add Binary | [Link](https://leetcode.com/problems/add-binary/) | [Link](./lib/easy/add_binary.dart) |
28+
| 69. Sqrt(x) | [Link](https://leetcode.com/problems/sqrtx/) | [Link](./lib/easy/sqrt_x.dart) |

lib/easy/sqrt_x.dart

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import 'dart:math';
2+
3+
// https://leetcode.com/problems/sqrtx/
4+
class Solution {
5+
int mySqrt(int x) {
6+
return sqrt(x).toInt();
7+
}
8+
}

test/easy/sqrt_x_test.dart

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import 'package:leetcode_dart/easy/sqrt_x.dart';
2+
import 'package:test/test.dart';
3+
4+
void main() {
5+
group(
6+
'Example tests',
7+
() {
8+
final sx = Solution();
9+
test('2', () => expect(2, sx.mySqrt(4)));
10+
test('2', () => expect(2, sx.mySqrt(8)));
11+
},
12+
);
13+
}

0 commit comments

Comments
 (0)