PIXNET Logo登入

程式小試身手

跳到主文

歡迎光臨!這裡紀錄著程式相關資料 有幫助或沒幫助請留言 希望可以找出各位盲點

部落格全站分類:不設分類

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 2月 22 週二 202207:19
  • 【Android Studio】License for package Android SDK Build-Tools 30.0.3 not accepted

image
參考了這個網址 解決問題
https://blog.csdn.net/weixin_45625639/article/details/122288602
(繼續閱讀...)
文章標籤

程式小試身手 發表在 痞客邦 留言(0) 人氣(1)

  • 個人分類:
▲top
  • 1月 31 週一 202209:59
  • 【LeetCode】Spiral Matrix

第一次想這題時方向不太對
class Solution {
    public List<Integer> spiralOrder(int[][] matrix) {
        //index[m] 走0~n.length-1格
        //index[m+1] 走 最後(n-1)
        //index[m+2] 走 n-1~ 0
        //回到index[m+1]走 0~n-2
        int m=matrix.length;
        int n=matrix[0].length;
        int i=0;
        int r_index=0;
        List<Integer> result= new ArrayList<Integer>();
        
        while(i<m){//>字型走法
           if(i==0){//第一列
              int j=0;
              while(j<n){
                 result.add(matrix[i][j++]);
              }
            }else if(i==m-1){//最後一列
              int j=n-1;
              while(j>=0){
                 result.add(matrix[i][j--]);
              }
            }else{//中間先走每一個matrix[i]最後一個index
               result.add(matrix[i][n-1]);
            }
            i++;
            r_index++;
        }
        //走中間每一個matrix[i]第一個index
        i=0;
        while(i<m&&m>2){
            if(i!=0&&i!=m-1){
                result.add(matrix[i][0]);
            }
            i++;
        }
        //....裡面的就要在循環一次>
        
        return result;
    }
}
(繼續閱讀...)
文章標籤

程式小試身手 發表在 痞客邦 留言(0) 人氣(0)

  • 個人分類:LeetCode
▲top
  • 1月 31 週一 202209:09
  • 【LeetCode】Pow(x, n)

第一個想法,暴力破解
class Solution {
    public double myPow(double x, int n) {
       int i=1;
       int round= Math.abs(n);//絕對值
       double result=0;
       result=x;
       while(i<round){
             result=x*result;
             i++;
            }
       if(n>0){
             return result;
       }else{
             return 1/result;
       }
    }
}
(繼續閱讀...)
文章標籤

程式小試身手 發表在 痞客邦 留言(0) 人氣(0)

  • 個人分類:LeetCode
▲top
  • 1月 30 週日 202207:15
  • 【LeetCode】筆記-Wildcard Matching

class Solution {
    public boolean isMatch(String str, String pattern) {
           int s = 0, p = 0, match = 0, starIdx = -1;            
        while (s < str.length()){
            // advancing both pointers
            if (p < pattern.length()  && (pattern.charAt(p) == '?' || str.charAt(s) == pattern.charAt(p))){
                s++;
                p++;
            }
            // * found, only advancing pattern pointer
            else if (p < pattern.length() && pattern.charAt(p) == '*'){
                starIdx = p;
                match = s;
                p++;
            }
           // last pattern pointer was *, advancing string pointer
            else if (starIdx != -1){
                p = starIdx + 1;
                match++;
                s = match;
            }
           //current pattern pointer is not star, last patter pointer was not *
          //characters do not match
            else return false;
        }
        
        //check for remaining characters in pattern
        while (p < pattern.length() && pattern.charAt(p) == '*')
            p++;
        
        return p == pattern.length();
    }
}
(繼續閱讀...)
文章標籤

程式小試身手 發表在 痞客邦 留言(0) 人氣(2)

  • 個人分類:LeetCode
▲top
  • 1月 29 週六 202208:32
  • 【LeetCode】Trapping Rain Water

image
把問題簡單化的話
(繼續閱讀...)
文章標籤

程式小試身手 發表在 痞客邦 留言(0) 人氣(0)

  • 個人分類:LeetCode
▲top
  • 1月 28 週五 202201:50
  • 【LeetCode】筆記-Next Permutation

 [1,2,3] 降冪題, 由尾來看 i=1, 3<2的話則往下比 , j=2, 2<1的話往下比。
swap([1,2,3],1,2]) --->[1,3,2]
(繼續閱讀...)
文章標籤

程式小試身手 發表在 痞客邦 留言(0) 人氣(0)

  • 個人分類:
▲top
  • 1月 27 週四 202205:11
  • 【LeetCode】筆記-Merge k Sorted Lists

解答中的分治法 (Divide-and-conquer algorithm)
class Solution {
    public static ListNode mergeKLists(ListNode[] lists){
    return partion(lists,0,lists.length-1);
}
(繼續閱讀...)
文章標籤

程式小試身手 發表在 痞客邦 留言(0) 人氣(1)

  • 個人分類:LeetCode
▲top
  • 1月 27 週四 202200:53
  • 【LeetCode】筆記-Generate Parentheses

一個"("必定有另一個")" 所以n=1時2*1, n=2時2*2,n=3時2*3, 總結就是2*n個符號
不可能有")"先開始,所以驗證時 "( "balance 只會為正或為 0,<0 直接 return false
(繼續閱讀...)
文章標籤

程式小試身手 發表在 痞客邦 留言(0) 人氣(0)

  • 個人分類:LeetCode
▲top
  • 1月 26 週三 202207:56
  • 【LeetCode】筆記Valid Parentheses

這題用stack真是太妙了
string "(" 則 stack放 ")" ,下一個如果是")" 就符合剛放進stack的
(繼續閱讀...)
文章標籤

程式小試身手 發表在 痞客邦 留言(0) 人氣(0)

  • 個人分類:LeetCode
▲top
  • 1月 26 週三 202207:11
  • 【LeetCode】筆記Letter Combinations of a Phone Number

未按任何號碼時,字串回傳空
按一個時回傳該數字對應的字串
(繼續閱讀...)
文章標籤

程式小試身手 發表在 痞客邦 留言(0) 人氣(1)

  • 個人分類:LeetCode
▲top
«1234...17»

個人資訊

程式小試身手
暱稱:
程式小試身手
分類:
不設分類
好友:
累積中
地區:

熱門文章

  • (247)【Android】自定義Card ListView-Eclipse與Android studio
  • (3,726)【D3.JS】繪製台灣地圖
  • (844)【Window Form C#】listbox與listview DragDrop 拖曳事件
  • (228)【JQuery】PQGrid欄位顯示與否
  • (451)【JQuery】File upload前是否檔案已存在的判斷
  • (615)【資安】JavaScript/ ASP.Net

文章分類

toggle 美食 (2)
  • 新竹 (1)
  • 高雄 (1)
toggle Cesium (1)
  • dae轉glft (1)
toggle Hybrid Apps (1)
  • 環境 (2)
toggle Ionic (1)
  • 環境 (1)
  • 威斯康辛 (2)
  • LeetCode (20)
  • .NET Core (3)
  • 資安 (2)
  • Python (10)
  • Android (54)
  • JavaScript (21)
  • D3.js (7)
  • ASP.NET MVC (7)
  • ASP.NET Web API (3)
  • ASP.NET Web Form C# (2)
  • SWT (1)
  • Github (3)
  • 課程 (1)
  • 其他 (4)
  • 未分類文章 (1)

最新文章

  • 威斯康辛生活費用2
  • MacBook Air 2017 Serria版本安裝失敗後製作USB解決
  • 威斯康辛生活費用
  • 高雄一日遊
  • 【LeetCode】between two sets
  • 【LeetCode】Parking Dilemma
  • 【LeetCode】bagOfTokensScore
  • 【LeetCode】The Coin Change Problem
  • 【Android】ListView 內的EditeText TextWatcher事件重複
  • 【Android】APP架構師實踐指南-閱讀心得

動態訂閱

文章精選

文章搜尋

誰來我家

參觀人氣

  • 本日人氣:
  • 累積人氣: