原创 【原創】456. 132 Pattern -- Leetcode算法筆記
[LeetCode. 456 132 Pattern] https://leetcode.com/problems/132-pattern/description/ 題目描述: 找出整型數組nums是否存在“132”模式,(“13
原创 【原創】正負例樣本失衡及focal loss
前段時間在解決分類任務時,發現當正負例比例相差較大時,分類算法更傾向於優化比例較大的類別的loss,最終導致正負例上的正確率有極大懸殊(正例正確率遠低於負例)。 這其實是做分類任務時經常遇到的問題,即正負例比例不均衡,解決此類問題
原创 【原創】715. Range Module -- Leetcode 算法筆記
LeetCode 715. Range Module 題目要求高效地實現區間的添加,刪除和查詢操作。 題目分析:本題是一道設計題,要求實現一個類(Range Module)的三個方法:addRange(int, int), que
原创 【原創】678. Valid Parenthesis String --Leetcode算法筆記
LeetCode 678. Valid Parenthesis String **題目描述:**輸入一個僅包含'(',')'和'*'的字符串,判斷字符串左右括號是否匹配,其中'*'可表示左括號,右括號或者爲空。 題目分析: 方法一
原创 【原創】8. String to Integer (atoi) leetcode算法筆記
Implement atoi to convert a string to an integer. step1.去掉空格; step2.判斷±號; step3.依次遍歷,如果爲0~9,則base*10加上該數字,將得到的值賦給bas
原创 【原創】23.Merge k Sorted Lists --- leetcode
public static ListNode mergeKLists(ListNode[] lists){ return partion(lists,0,lists.length-1); } public static
原创 【原創】3. Longest Substring Without Repeating Characters --- leetcode算法筆記
Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the
原创 【原創】148. Sort List --- leetcode
Sort a linked list in O(n log n) time using constant space complexity. 思路:歸併排序 代碼: public ListNode sortList(ListNode
原创 【原創】278. First Bad Version
思路:由於version可以看作有序的,查找有序數組的某一個元素,用二分查找算法。 代碼: public int firstBadVersion(int n) { if(isBadVersion(1)) return
原创 【原創】13. Roman to Integer leetcode算法筆記
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 羅馬數字與阿拉伯數
原创 【原創】48. Rotate Image ---leetcode算法筆記
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could yo
原创 【原創】27. Remove Element ---leetcode算法筆記
Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extr
原创 【原創】83. Remove Duplicates from Sorted List leetcode算法筆記
Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2,
原创 【原創】75. Sort Colors --- one-pass algorithm --- leetcode算法筆記
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, wit
原创 【原創】46. Permutations --- leetcode 算法筆記
Given a collection of distinct numbers, return all possible permutations. 思路:若前n個數已經排好,則第n+1個數只需插入到前n個數中即形成前n+1個數的全部排列。