【計劃執行報告】Day15 不知做什麼就刷題吧

今天是:

  1. 計劃執行的第15

1. 近期事件線

計劃趕不上變化,今天突然又多了兩波新能源熱利用作業,猝不及防,因此對於事件線與周計劃進行了微調。
在這裏插入圖片描述

2. 第9周計劃

在這裏插入圖片描述

3.今日計劃執行情況

04-14

圖1 時間分配
圖2 目標完成情況

4.明日計劃

04-15

【今日知識梳理】

1.《ML中的數學》

第9章 曲線救國

  1. 參數方程,其中注意下襬線方程就好了:x=a(θsinθ),y=a(1cosθ)x=a(\theta-sin\theta),y=a(1-cos\theta)

第10章 超越直角座標系

  1. 直角座標–>平面極座標;
  2. 直角座標–>柱座標:dzdydx>rdzdrdθdzdydx ->rdzdrd\theta;
  3. 直角座標–>球座標:dzdxdy>r2sinϕdrdϕdθdzdxdy->r^2sin\phi drd\phi d\theta;
  4. 注意各個維度的積分域。

2.《ML算法視角》

第12章 樹的學習

  1. 信息熵的表示法
  2. 決策樹ID3算法流程以及代碼實現

3.Leetcode競賽練習

今天的練習情況:
在這裏插入圖片描述

  1. 隊列設計
    class MyCircularQueue {
    private:
        vector<int> v;
        int head;
        int tail;
        int size;
    public:
        /** Initialize your data structure here. Set the size of the queue to be k. */
        MyCircularQueue(int k) {
            v.resize(k);
            head=-1;
            tail=-1;
            size=k;
        }
        
        /** Insert an element into the circular queue. Return true if the operation is successful. */
        bool enQueue(int value) {
            if(isFull())
                return false;
            if(isEmpty())
                head=0;
            tail=(tail+1)%size;
            v[tail]=value;
            return true;
        }
        
        /** Delete an element from the circular queue. Return true if the operation is successful. */
        bool deQueue() {
            if(isEmpty())
                return false;
            if(head==tail){ //only one element
                head=-1;
                tail=-1;
                return true;
            }
            head=(head+1)%size;
            return true;
        }
        
        /** Get the front item from the queue. */
        int Front() {
            if(isEmpty())
                return -1;
            
            return v[head];
        }
        
        /** Get the last item from the queue. */
        int Rear() {
            if(isEmpty())
                return -1;
                
            return v[tail];
        }
        
        /** Checks whether the circular queue is empty or not. */
        bool isEmpty() {
            return head==-1;
        }
        
        /** Checks whether the circular queue is full or not. */
        bool isFull() {
            return head==(tail+1)%size;
        }
    };
    
    /**
     * Your MyCircularQueue object will be instantiated and called as such:
     * MyCircularQueue* obj = new MyCircularQueue(k);
     * bool param_1 = obj->enQueue(value);
     * bool param_2 = obj->deQueue();
     * int param_3 = obj->Front();
     * int param_4 = obj->Rear();
     * bool param_5 = obj->isEmpty();
     * bool param_6 = obj->isFull();
     */
    
  2. 棧的應用——括號匹配
    class Solution {
    public:
        bool isValid(string s) {
            if(s.length()==0)
                return true;
            stack<char> st;
            st.push(s[0]);
            int i=1,size=s.length();
            while(i<size){
            if(s[i]=='['||s[i]=='('||s[i]=='{'){
                st.push(s[i++]);
                continue;
            }       
             if(!st.empty()){  
                if(s[i]==']'&&st.top()!='['||s[i]==')'&&st.top()!='('||s[i]=='}'&&st.top()!='{')
                        return false;
                else if(s[i]==')'&&st.top()=='('||s[i]==']'&&st.top()=='['||s[i]=='}'&&st.top()=='{')
                    st.pop();
            }
            else{
                if(s[i]==')'||s[i]==']'||s[i]=='}')
                    return false;
            }
            i++;  
            }
    
           return st.empty();
        }
    };
    
    
  3. 虛擬競賽No183——【1403】 非遞增順序的最小子序列
    【題目描述】
    在這裏插入圖片描述
    【思路】希爾排序(O(Nlog2N)O(Nlog_2N)),之後就依題意照做即可(暫時不知道O(N2)O(N^2)排序能不能行)
class Solution {
public:
    int sum(vector<int> v,int size){
        int ans=0;
        for(int i=0;i<size;i++){
            ans+=v[i];
        }
        return ans;
    }
    void swap(int& a,int& b){
        a^=b^=a^=b;
    }
    void shellSort(vector<int>& v,int size){
        int gap=size;
        while(gap/2){
            gap/=2;
            int flag=1;
            do{
                flag=0;
                for(int i=0;i<size-gap;i++){
                    if(v[i]<v[i+gap]){
                        swap(v[i],v[i+gap]);
                        flag=1;
                    }     
                }
            }while(flag);       
        }
    }
    vector<int> minSubsequence(vector<int>& nums) {
        int size=nums.size();
        vector<int> ret;
        if(size==0)return ret;
        else if(size==1) return nums;
        
        shellSort(nums,size);
        int ans=0,sum=0;      
        for(int i=0;i<size;i++){
            sum+=nums[i];
        }
        for(int i=0;i<size;i++){
            if(ans+nums[i]<=sum-ans-nums[i]){
                ans+=nums[i];
                ret.push_back(nums[i]);
            }     
            else{
                ret.push_back(nums[i]);
                break;
            }
                
        }
        return ret;
    }
};
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章