[leetcode]3318. Find X-Sum of All K-Long Subarrays I
輸入一個數字陣列nums以及數字k和x,以nums中每k個為一組(1~k, 2~k+1 ...)統計各數字的出現次數,依照次數由多到少,同次數由數字大到小排序,將前x個數字出現的總值相加,輸出一個由這些總值組成的陣列。
[leetcode]929. Unique Email Addresses
輸入多個符合要求的全小寫信箱地址(確定中間有一個@字元),請判斷傳入參數當中有幾個不重複的信箱地址。
[leetcode]程式記錄、測試方式大改版
比起單純記錄答題得到的答案,把解題過程可以驗證的測試架構也一起建好,作為磨練程式的歷程應該會更有價值吧
[leetcode]448. Find All Numbers Disappeared in an Array
輸入的數字陣列長度為N,理想上其中應包含1~N各一個,請回傳缺少了哪些數字。
[leetcode]217. Contains Duplicate
判斷輸入的數字陣列是否包含重複的數字。
[leetcode]1003. Check If Word Is Valid After Substitutions
確認一個字串,在形成的過程是否從空字串開始,透過在字串的任意位置插入"abc"的字串而形成。
[leetcode]20. Valid Parentheses
輸入一個字串僅由'('、')'、'['、']'、'{'、'}'等左右括號字元組成,請寫程式判斷字串是否由合乎規則的成對括號組成。※:本題推薦正在學習資料結構的學生練習。
LeetCode 2235. Add Two Integers
class Solution { public int sum(int num1, int num2) { return num1+num2; } }
LeetCode 1672. Richest Customer Wealth (Java)
class Solution { public int maximumWealth(int[][] accounts) { int max=0; for(int[] i1: accounts){ int wealth...
LeetCode 1342. Number of Steps to Reduce a Number to Zero (Java)
class Solution { public int numberOfSteps(int num) { int i=0; int n=num; do{ if(n%2 == 0){ ...
LeetCode 876. Middle of the Linked List (Java)
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNo...
LeetCode 724. Find Pivot Index (Java)
class Solution { public int pivotIndex(int[] nums) { int sum, leftsum; sum = 0; leftsum = 0; for(int ...
LeetCode 412. Fizz Buzz
class Solution { public List String fizzBuzz(int n) { ArrayList String al = new ArrayList (n); al.c...
LeetCode 412. Fizz Buzz
class Solution { public List String fizzBuzz(int n) { ArrayList String al = new ArrayList (n); al.c...
LeetCode 205. Isomorphic Strings
class Solution { public boolean isIsomorphic(String s, String t) { if(s.length()!=t.length()){ return ...
LeetCode 9. Palindrome Number
class Solution { public boolean isPalindrome(int x) { if(x 0 (x % 10 == 0 x != 0)) { return false; ...
Javascript in Leetcode 22–24 | 面試問題
目錄22. Generate Parentheses23. Merge k Sorted Lists24. Swap Nodes in Pairs找到source code Github22. Generate Parenthesesleetcode
Javascript in Leetcode 19–21 | 面試問題
目錄19-Remove-Nth-Node-From-End-of-List17-Letter-Combinations-of-a-Phone-Number18–4Sum找source code Github19. Remove Nth Node From End of ListLeetcode
Javascript in Leetcode 13–15|面試問題
目錄13-Roman-to-Integer14-Longest-Common-Prefix15–3Sum找到source code Github13. Roman to IntegerRoman numerals are represented by seven differe...
Javascript in Leecode 10–12 | 面試問題
source code在此 Github10. Regular Expression MatchingGiven an input string s and a pattern p, implement regular expression matching with sup...