Skip to content

Commit b30dda0

Browse files
committed
update sm
1 parent a72cb05 commit b30dda0

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

Algorithm/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1. [约瑟夫环]()

Algorithm/joseph-ring.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# coding: utf-8
2+
# %load python/Algorithm/joseph-ring.py
3+
def joseph_ring(n, m):
4+
if n < 1:
5+
return -1
6+
7+
result = -1
8+
start = 0
9+
10+
ring_num = list(range(n))
11+
while ring_num:
12+
k = (start + m - 1) % n
13+
result = ring_num.pop(k)
14+
n -= 1
15+
start = k
16+
return result
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding:utf-8 -*-
2+
class ListNode:
3+
def __init__(self, x):
4+
self.val = x
5+
self.next = None
6+
7+
class Solution:
8+
# 返回从尾部到头部的列表值序列,例如[1,2,3]
9+
def printListFromTailToHead(self, listNode):
10+
# write code here
11+
res = []
12+
if listNode is None:
13+
return res
14+
while listNode:
15+
res.append(listNode.val)
16+
listNode = listNode.next
17+
res.reverse()
18+
return res

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
10. [Python与数据库](https://www.zybuluo.com/Scrazy/note/702005)
1313
11. [新浪博客抓取及简单聚类](https://www.zybuluo.com/mdeditor#709348)
1414
12. [Python 算法教程 笔记](https://www.zybuluo.com/Scrazy/note/530998)
15+
13. [TCP简述](https://www.zybuluo.com/Scrazy/note/717147)

0 commit comments

Comments
 (0)