diff --git a/.travis.yml b/.travis.yml index f52bbce..38a4c85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,12 @@ language: node_js node_js: - - "6" + - "10" addons: chrome: stable -before_script: - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" - - sleep 3 # give xvfb some time to start +services: + - xvfb before_install: npm install karma-cli -g \ No newline at end of file diff --git a/quz/quz.js b/quz/quz.js index 624e7de..ac01409 100755 --- a/quz/quz.js +++ b/quz/quz.js @@ -9,6 +9,12 @@ */ function dcate(A, B) { /** Fill in here **/ + let currList = A + while (currList.tail !== null) { + currList = currList.tail; + } + currList.tail = B; + return A; } /** @@ -24,4 +30,18 @@ function dcate(A, B) { */ function sub(L, start, len) { /** Fill in here **/ + if (!L || !(/(^[0-9]\d*$)/.test(start)) || !(/(^[0-9]\d*$)/.test(len))) throw new Error('param error'); + let newList = [], + subLen = 0, + currList = L, + currIndex = 0 + do { + if (currIndex >= start){ + newList.push(currList.head); + subLen++; + } + currList = currList.tail; + currIndex++; + } while (len !== subLen && currList !== null); + return new List.list(newList); }