日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

5.16 学习记录

發布時間:2025/5/22 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 5.16 学习记录 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

項目學習

在打包時,通過-P XXX指令,指定打入jar的配置環境

在Pom中的profiles profile 標簽下 如:

<id> dev </id> <properties></profiles> <profiles.active>dev<profiles.active> <activeProfile>dev</activeProfile> <logLevel>info</logLevel> <properties> <activation> <activeByDefault> true </activeByDefault> </activation> 復制代碼

與配置文件application-dev.yml對應,若在打包時的指令為-P dev 則會將其配置進去

fourinone分布式系統開發

個人任務:分布式調度模塊的開發 參考yarn

本周任務:學習yarn和fourinone相關模塊代碼,確定api接口

每日一題

題目:給定一個包括 n 個整數的數組 nums 和 一個目標值 target。找出 nums 中的三個整數,使得它們的和與 target 最接近。返回這三個數的和。假定每組輸入只存在唯一答案。

例如,給定數組 nums = [-1,2,1,-4], 和 target = 1. 與 target 最接近的三個數的和為 2. (-1 + 2 + 1 = 2).

思路

首先將原數組排序,成為一個有序數組。

因為是三數之和,所以遍歷數組確定第一個數,成為哨兵,用兩個指針表示第二個數和第三個數。

兩個指針初始分別指向除哨兵外最小的數和最大的數(也就是最左邊和最右邊),當左指針下標小于右指針時進行循環,計算三數之和,如果三數之和比結果值更接近target,則更新target。若三數之和小于taget,則將左指針向右移;反之則將右指針向左移。當然如果和恰好等于target,直接返回target。

代碼

public static int threeSumClosest(int[] nums, int target) {Arrays.sort(nums);int result = nums[0] + nums[1] + nums[2];for(int i = 0; i< nums.length-2; i++) {int l = i+1;int r = nums.length - 1 ;while( l < r) {int threeNum = nums[i] + nums[l] +nums[r];if(Math.abs(threeNum - target) < Math.abs(result - target)) {result = threeNum;}if(threeNum < target) {l++;} else if(threeNum > target) {r--;} else return target;}}return result;} 復制代碼

轉載于:https://juejin.im/post/5cdd00d3e51d453ce71f6117

總結

以上是生活随笔為你收集整理的5.16 学习记录的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。