This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function flex_calc(container, items = []){ | |
| var cs = (arr) => arr.reduce((p, c) => p + c, 0) - container; | |
| var t = items.slice(0); | |
| var s = cs(t.map(i => i[2])); | |
| if(s < 0){ | |
| var tg = t.reduce((p, c) => p + c[0], 0); | |
| if(tg == 0) return t.map(i => i[2]); | |
| return t.map(i => i[2] - s * i[0] / tg); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {number[]} nums1 | |
| * @param {number[]} nums2 | |
| * @return {number} | |
| */ | |
| var findMedianSortedArrays = function(A, B) { | |
| //確保A > B | |
| if(A.length < B.length){ | |
| let tmp = A; | |
| A = B; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {string} s | |
| * @return {number} | |
| */ | |
| var lengthOfLongestSubstring = function(s) { | |
| let result = 0, | |
| str = ''; | |
| for(let i = 0; i < s.length; i++){ | |
| let c = s[i], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Date.prototype.format = (function () { | |
| var month_str = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; | |
| var day_str = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; | |
| function ParseRepeatPattern(str, pos, char) { | |
| var len = str.length; | |
| var num = pos + 1; | |
| while (num < len && str.substr(num, 1) == char) { | |
| num++; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var pngfix = function (option) { | |
| if (true || navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) { | |
| if (!document.getElementsByClassName) { | |
| document.getElementsByClassName = function (classname) { | |
| var all = document.documentElement.all || document.all; | |
| var elem, list, ret = []; | |
| for (var i = 0; i < all.length; i++) { | |
| elem = all[i]; | |
| if (elem.className != "") { | |
| list = elem.className.split(' '); |