@@ -55,6 +55,85 @@ var runningSum = function (nums) {
5555 * @return {number }
5656 */
5757var minCount = function ( coins ) {
58-
58+
5959} ;
60- console . log ( runningSum ( [ 1 , 2 , 3 , 4 ] ) )
60+ // console.log(runningSum([1, 2, 3, 4]))
61+
62+
63+ /**
64+ * @param {string } jewels
65+ * @param {string } stones
66+ * @return {number }
67+ */
68+ export var numJewelsInStones = function ( jewels = "ebd" , stones = "bbb" ) {
69+ const res = stones . match ( new RegExp ( jewels . split ( "" ) . join ( "+|" ) + "+" , "g" ) )
70+ console . log ( res )
71+ if ( res == null ) return 0
72+ let num = 0 ;
73+ res . forEach ( ele => {
74+ num += ele . length
75+ } )
76+ return num
77+ } ;
78+
79+ /**
80+ * @param {number[][] } accounts
81+ * @return {number }
82+ */
83+ export var maximumWealth = function ( accounts = [ [ 1 , 2 , 3 ] , [ 3 , 2 , 1 ] ] ) {
84+ let res = 0 ;
85+ for ( let i = 0 ; i < accounts . length ; i ++ ) {
86+ let temp = 0
87+ for ( let j = 0 ; j < accounts [ i ] . length ; j ++ ) {
88+ temp += accounts [ i ] [ j ] ;
89+ }
90+ res = Math . max ( temp , res )
91+ }
92+ return res
93+ } ;
94+
95+ // 给你一个整数数组 nums 。
96+
97+ // 如果一组数字 (i,j) 满足 nums[i] == nums[j] 且 i < j ,就可以认为这是一组 好数对 。
98+
99+ // 返回好数对的数目。
100+
101+ // 输入:nums = [1,2,3,1,1,3]
102+ // 输出:4
103+ // 解释:有 4 组好数对,分别是 (0,3), (0,4), (3,4), (2,5) ,下标从 0 开始
104+ /**
105+ * @param {number[] } nums
106+ * @return {number }
107+ */
108+ export var numIdenticalPairs = function ( nums = [ 1 , 2 , 3 , 1 , 1 , 3 ] ) {
109+ let res = 0
110+ for ( let i = 0 ; i < nums . length ; i ++ ) {
111+ for ( let j = i + 1 ; j < nums . length ; j ++ ) {
112+ if ( nums [ i ] === nums [ j ] ) {
113+ res ++
114+ }
115+ }
116+ }
117+ return res
118+ } ;
119+
120+ // 给你一个二进制字符串 s 。如果字符串中由 1 组成的 最长 连续子字符串 严格长于 由 0 组成的 最长 连续子字符串,返回 true ;否则,返回 false 。
121+
122+ // 例如,s = "110100010" 中,由 1 组成的最长连续子字符串的长度是 2 ,由 0 组成的最长连续子字符串的长度是 3 。
123+ // 注意,如果字符串中不存在 0 ,此时认为由 0 组成的最长连续子字符串的长度是 0 。字符串中不存在 1 的情况也适用此规则。
124+
125+ /**
126+ * @param {string } s
127+ * @return {boolean }
128+ */
129+ export var checkZeroOnes = function ( s = "1" ) {
130+ const one = s . match ( / 1 + / g) || [ ]
131+ const o = s . match ( / 0 + / g) || [ ]
132+ let onelen = 0 , olen = 0 ;
133+ one . forEach ( ele => ele . length > onelen ? onelen = ele . length : null )
134+ o . forEach ( ele => ele . length > olen ? olen = ele . length : null )
135+ if ( onelen > olen ) {
136+ return true
137+ }
138+ return false
139+ } ;
0 commit comments