diff --git a/.travis.yml b/.travis.yml index f52bbce..493cb22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,19 @@ language: node_js node_js: - - "6" + - "8" addons: chrome: stable +services: + - xvfb + before_script: - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" - sleep 3 # give xvfb some time to start before_install: - npm install karma-cli -g \ No newline at end of file + npm install karma-cli -g + +script: + karma start karma.conf.js --single-run \ No newline at end of file diff --git a/quz/quz.js b/quz/quz.js index 624e7de..67b08b7 100755 --- a/quz/quz.js +++ b/quz/quz.js @@ -9,6 +9,22 @@ */ function dcate(A, B) { /** Fill in here **/ + /** + * 思路: + * 1. 循环找到A.tail的末尾(null) + * 2. 在末尾.tail加上B + */ + + let leaf = A; + + while (leaf.tail) { + leaf = leaf.tail; + } + + leaf.tail = B; + + return A; + } /** @@ -24,4 +40,27 @@ function dcate(A, B) { */ function sub(L, start, len) { /** Fill in here **/ + /** + * + */ + let result = new List(L.head, L.tail); + let index = 0; + + let temp; + + while (index <= start + len - 1) { + if(index < start) { + result = result.tail; + temp = result; + } else if (index === start + len - 1) { + temp.tail = null; + } else { + temp = temp.tail; + } + + index += 1; + }; + + return result; + }