Skip to content

Commit 37555fe

Browse files
committed
docs: Binary Gap
1 parent 21036af commit 37555fe

File tree

1 file changed

+66
-0
lines changed
  • Codility/Lesson/0001.Iterations/Binary-Gap

1 file changed

+66
-0
lines changed

Diff for: Codility/Lesson/0001.Iterations/Binary-Gap/README.md

+66
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,64 @@
1+
---
2+
title: Binary Gap
3+
subtitle: "https://app.codility.com/programmers/lessons/1-iterations/binary_gap/"
4+
date: 2021-04-18T12:09:00+08:00
5+
lastmod: 2021-04-18T12:09:00+08:00
6+
draft: false
7+
author: "Kimi.Tsai"
8+
authorLink: "https://kimi0230.github.io/"
9+
description: "Binary Gap"
10+
license: ""
11+
images: []
12+
13+
tags: [Codility, Go, Iterations, Painless, Bitwise Manipulation]
14+
categories: [Codility]
15+
16+
featuredImage: ""
17+
featuredImagePreview: ""
18+
19+
hiddenFromHomePage: false
20+
hiddenFromSearch: false
21+
twemoji: false
22+
lightgallery: true
23+
ruby: true
24+
fraction: true
25+
fontawesome: true
26+
linkToMarkdown: false
27+
rssFullText: false
28+
29+
toc:
30+
enable: true
31+
auto: true
32+
code:
33+
copy: true
34+
maxShownLines: 200
35+
math:
36+
enable: false
37+
# ...
38+
mapbox:
39+
# ...
40+
share:
41+
enable: true
42+
# ...
43+
comment:
44+
enable: true
45+
# ...
46+
library:
47+
css:
48+
# someCSS = "some.css"
49+
# located in "assets/"
50+
# Or
51+
# someCSS = "https://cdn.example.com/some.css"
52+
js:
53+
# someJS = "some.js"
54+
# located in "assets/"
55+
# Or
56+
# someJS = "https://cdn.example.com/some.js"
57+
seo:
58+
images: []
59+
# ...
60+
---
61+
162
# [BinaryGap](https://app.codility.com/programmers/lessons/1-iterations/binary_gap/)
263
START
364
Find longest sequence of zeros in binary representation of an integer.
@@ -25,6 +86,11 @@ Copyright 2009–2021 by Codility Limited. All Rights Reserved. Unauthorized cop
2586

2687
## 解題思路
2788
先找出bit 1的位子, 再開始算中間最長的長度
89+
解題思路通常可以使用位運算來處理二進制數字。我們可以將N轉換為二進制表示,然後使用遍歷或迴圈來找到相鄰1之間的最大距離。可以使用兩個指針來記錄相鄰的1的
90+
91+
時間複雜度: 解題思路中的遍歷或迴圈需要將N轉換為二進制,因此時間複雜度取決於二進制表示的位數。假設N的位數為k,則時間複雜度為O(k)。
92+
93+
空間複雜度: 解題思路中不需要使用額外的數據結構,只需要使用幾個變數來保存位置和計算結果,因此空間複雜度為O(1)。
2894

2995
## 來源
3096
* https://app.codility.com/programmers/lessons/1-iterations/binary_gap/

0 commit comments

Comments
 (0)