2024年01月29日 09:24:14

2024年1月27号,跑章地:辽宁美术馆,城市规划馆,万豪酒店,k11,广电博物馆,文化路万达,盛京龙城,盛京大家庭,大悦城乐高,大悦城霸王别姬(集章送茶饮),全运路万达(需要消费9.9)

2023年11月24日 11:36:19

力扣每日一题

题目:[2824. 统计和小于目标的下标对数目](https://leetcode.cn/problems/count-pairs-whose-sum-is-less-than-target/description/)

日期:2023-11-24

用时:14 m 38 s

时间:2ms

内存:40.59MB

代码:

java
  • 01
  • 02
  • 03
  • 04
  • 05
  • 06
  • 07
  • 08
  • 09
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
class Solution { public int countPairs(List<Integer> nums, int target) { Collections.sort(nums); int cnt = 0; int index = nums.size()-1; for(int i=0;i<index;i++){ while(nums.get(i)+nums.get(index)>=target&&index>i){ index--; } if(nums.get(i)+nums.get(index)<target){ cnt+=index-i; } } return cnt; } }

2023年11月23日 10:33:52

力扣每日一题

题目:[1410. HTML 实体解析器](https://leetcode.cn/problems/html-entity-parser/description/)

日期:2023-11-23

用时:4 m 57 s

时间:34ms

内存:42.68MB

代码:

java
  • 01
  • 02
  • 03
  • 04
  • 05
  • 06
  • 07
  • 08
  • 09
class Solution { public String entityParser(String text) { return text.replaceAll("&quot;", "\"") .replaceAll("&apos;","'") .replaceAll("&gt;",">") .replaceAll("&lt;","<") .replaceAll("&frasl;","/") .replaceAll("&amp;","&"); } }

2023年11月21日 09:54:33

力扣每日一题

题目:[2216. 美化数组的最少删除数](https://leetcode.cn/problems/minimum-deletions-to-make-array-beautiful/description/)

日期:2023-11-21

用时:11 m 23 s

时间:3ms

内存:54.23MB

代码:

java
  • 01
  • 02
  • 03
  • 04
  • 05
  • 06
  • 07
  • 08
  • 09
  • 10
class Solution { public int minDeletion(int[] nums) { int cnt = 0; for(int i=0;i<nums.length;i++){ if((i - cnt) % 2 == 0 && i + 1 < nums.length && nums[i] == nums[i + 1]){ cnt +=1; } } return (nums.length-cnt)%2==0?cnt:cnt+1; } }

2023年11月16日 15:16:23

力扣每日一题

题目:[2760. 最长奇偶子数组](https://leetcode.cn/problems/longest-even-odd-subarray-with-threshold/description/)

日期:2023-11-16

用时:1 m 33 s

时间:4ms

内存:41.76MB

代码:

python
  • 01
  • 02
  • 03
  • 04
  • 05
  • 06
  • 07
  • 08
  • 09
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
class Solution { public int longestAlternatingSubarray(int[] nums, int threshold) { int max = 0; int cnt = 0; for(int i=0;i<nums.length;i++){ if(cnt==0){ if(nums[i]%2==0&&nums[i]<=threshold){ cnt++; } }else { if(i>0&&nums[i] % 2 != nums[i - 1] % 2&&nums[i]<=threshold){ cnt++; }else{ max = Math.max(max,cnt); if(nums[i]%2==0&&nums[i]<=threshold){ cnt=1; }else{ cnt=0; } } } } return Math.max(max,cnt); } }

2023年11月15日 15:03:29

力扣每日一题,用时: 1 m 33 s

题目:[2656. K 个元素的最大和](https://leetcode.cn/problems/maximum-sum-with-exactly-k-elements/description/)

代码:

python
  • 01
  • 02
  • 03
  • 04
  • 05
  • 06
  • 07
  • 08
  • 09
  • 10
  • 11
class Solution { public int maximizeSum(int[] nums, int k) { Arrays.sort(nums); int sum = 0; int num = nums[nums.length-1]; for(int i=0;i<k;i++){ sum+=num; num++; } return sum; } }

2023年11月14日 10:54:22

力扣每日一题,花费时间00:49:28

2023年11月13日 16:23:18

记录一下代码片段,通过Python批量修改图片名,改为IMG_年月日_时分秒.原始后缀(例如:IMG_20231111_170415.jpeg),代码是pyhton3.10

python
  • 01
  • 02
  • 03
  • 04
  • 05
  • 06
  • 07
  • 08
  • 09
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
import os import glob import exifread # 获取照片的拍摄时间 def get_photo_taken_time(image_path): with open(image_path, 'rb') as f: tags = exifread.process_file(f) if 'EXIF DateTimeOriginal' in tags: taken_time = tags['EXIF DateTimeOriginal'] return taken_time else: return None def solution(): # 获取当前时间并格式化为年月日时分秒毫秒 # 设置照片所在的文件夹路径 folder_path = "C:\\Users\\Administrator\\Pictures\\图片" # 获取文件夹中的所有照片文件 photo_files = glob.glob(os.path.join(folder_path, "*")) # 遍历照片文件并重命名 for photo in photo_files: creation_time_stamp = get_photo_taken_time(photo) if creation_time_stamp is None: continue formatted_time = "IMG_" + creation_time_stamp.values.replace(':', '').replace(' ', '_') file_name, file_ext = os.path.splitext(photo) new_file_name = f"{formatted_time}{file_ext}" new_file_path = os.path.join(folder_path, new_file_name) os.rename(photo, new_file_path) print("照片重命名完成!") if __name__ == "__main__": solution()

2023年07月19日 20:29:35

嘿嘿

2023年06月20日 15:53:48

测试