Skip to content

Instantly share code, notes, and snippets.

View OriLiMu's full-sized avatar
😃
热爱生命

Ori OriLiMu

😃
热爱生命
View GitHub Profile
@OriLiMu
OriLiMu / kde_set_proxy_in_cmdl.sh
Created August 20, 2024 21:41
set proxy in command line in kde when setting is down by qt
kwriteconfig6 --file kioslaverc --group 'Proxy Settings' --key ProxyType "1"
kwriteconfig6 --file kioslaverc --group 'Proxy Settings' --key 'httpProxy' 'http://127.0.0.1:10081'
kwriteconfig6 --file kioslaverc --group 'Proxy Settings' --key 'httpsProxy' 'http://127.0.0.1:10081'
kwriteconfig6 --file kioslaverc --group 'Proxy Settings' --key 'ftpProxy' 'http://127.0.0.1:10081'
kwriteconfig6 --file kioslaverc --group 'Proxy Settings' --key Authmode 0
# When you modify kioslaverc, you need to tell KIO.
dbus-send --type=signal /KIO/Scheduler org.kde.KIO.Scheduler.reparseSlaveConfiguration string:''
@OriLiMu
OriLiMu / LC_4.py
Created October 8, 2024 03:55
LC4. 最简单的双指针的解法
class Solution:
def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:
l1 = len(nums1)
l2 = len(nums2)
total_len = 0
index1 = 0
index2 = 0
last1 = 0
last2 = 0
while True:
@OriLiMu
OriLiMu / MergeSort.py
Created October 8, 2024 06:03
merge sort
def merge_sort(arr):
if len(arr) > 1:
mid = len(arr) // 2 # Finding the mid of the array
L = arr[:mid] # Dividing the elements into 2 halves
R = arr[mid:]
merge_sort(L) # Sorting the first half
merge_sort(R) # Sorting the second half
@OriLiMu
OriLiMu / quicksort.py
Created October 9, 2024 01:06
quicksort
def quick_sort_iterative(arr):
stack = [(0, len(arr) - 1)] # 定义一个栈,用于存储待排序的区间
while stack:
start, end = stack.pop() # 从栈中弹出一个区间
if start >= end:
continue
pivot = arr[end] # 选择最后一个元素作为枢轴
partition_index = start # 分区的索引
@OriLiMu
OriLiMu / ReverseChainList.cpp
Last active January 25, 2025 14:20
ReverseChainList
#include <cstddef>
#include <iostream>
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode() : val(0), next(nullptr) {}
ListNode(int x) : val(x), next(nullptr) {}
@OriLiMu
OriLiMu / mergeTwoLists.cpp
Created January 25, 2025 06:09
mergeTwoSortedList
#include <iostream>
// nested way
struct ListNode {
int val;
ListNode *next;
ListNode() : val(0), next(nullptr) {}
ListNode(int x) : val(x), next(nullptr) {}
ListNode(int x, ListNode *next) : val(x), next(next) {}
};
@OriLiMu
OriLiMu / factorial.cpp
Created January 28, 2025 10:50
阶乘factorial
#include <iostream>
using namespace std;
long long factorial(int n) {
if (n == 0 || n == 1) {
return 1;
}
long long result = 1;
for (int i = 2; i <= n; ++i) {
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstddef>
#include <iostream>
#include <type_traits>
#include <vector>
using namespace std;
@OriLiMu
OriLiMu / getLastOfVec.cpp
Created January 28, 2025 16:41
get last item from vec
#include <iostream>
#include <vector>
int main() {
std::vector<int> vec = {1, 2, 3, 4, 5};
// 获取最后一个元素
int last_element = vec.back();
std::cout << "Last element: " << last_element << std::endl; // 输出 5
@OriLiMu
OriLiMu / 45_JumpGameII.cpp
Created January 29, 2025 07:40
代码可读性中文变量名
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdio>
#include <filesystem>
#include <iostream>
#include <vector>
using namespace std;