960. Delete Columns to Make Sorted III

You are given an array of n strings strs, all of the same length. We may choose any deletion indices, and we delete all the characters in those indices for each string. For example, if we have strs = ["abcdef","uvwxyz"] and deletion indices {0, 2, 3}, then the final array after deletions is ["bef", "vyz"]. Suppose we chose a set of deletion indices answer such that after deletions, the final array has every string (row) in lexicographic order. (i.e., (strs[0][0] <= strs[0][1] <= ... <= strs[0][strs[0].length - 1]), and (strs[1][0] <= strs[1][1] <= ... <= strs[1][strs[1].length - 1]), and so on). Return the minimum possible value of answer.length.
/**
 * @param {string[]} strs
 * @return {number}
 */
var minDeletionSize = function(strs) {
    const n = strs.length;        // number of rows
    const m = strs[0].length;     // number of columns (all strings same length)

    // dp[i] = length of the longest valid chain ending at column i
    const dp = Array(m).fill(1);

    // Helper: check if column j can come before column i
    // This requires strs[row][j] <= strs[row][i] for EVERY row
    function isValid(j, i) {
        for (let row

Word模拟手写

/*一、基于手写机、其他材料的 VBA 代码
优点是:同类字体的不同细节,可以更高的模拟手写情况。*/

Sub 模拟手写()
    Dim R_Character As Range
  
    '定义字体大小,随机选取以下大小,可以根据需要改写
    Dim FontSize(5)
    FontSize(1) = "16"
    FontSize(2) = "16.2"
    FontSize(3) = "16.5"
    FontSize(4) = "17"
    FontSize(5) = "17.2"
  
    '定义字体名称,随机选取以下名称,可以根据需要改写
    Dim FontName(7)
    FontName(1) = "郑大白"
    FontName(2) = "郑大风"
    FontName(3) = "郑大黑"
    FontName(4) = "郑大黄"
    FontName(5) = "郑大绿"
    FontName(6) = "郑大清"
    FontName(7

Excel自适应行高增加10

Sub 自适应行高()
	Set Rng = Range("a1").Resize(Range("a" & Rows.Count).End(xlUp).Row,1)
	Rng.Rows.AutoFit '自动行高
	For Each r In Rng.Rows
		r.RowHeight = r.RowHeight + 10
	Next
End Sub

Excel打印预览&所有行列缩放到一页

ActiveWindow.SelectedSheets.PrintPreview  '打印预览
ActiveSheet.PageSetup.FitToPagesTall = 1 '所有行缩放到一页
ActiveSheet.PageSetup.FitToPagesWide = 1 '所有列缩放到一页

Space(空格键)增强(作为修饰键)

#NoEnv
#SingleInstance, Force
SendMode, Input
SetBatchLines, -1
SetWorkingDir, %A_ScriptDir%
StringCaseSense, On

AnyKeyPressedOtherThanSpace(mode = "P") {
    keys = 1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./
    Loop, Parse, keys
    {    
        isDown :=  GetKeyState(A_LoopField, mode)
        if(isDown)
            return True
    }

    return False
}


supressed := False
RestoreInput(){
    BlockInput, Off
    Global supressed
    supressed := False
}

Supr

以管理员权限运行AutoHotkey脚本

; 将这段代码赋值到脚本最前面即可让本脚本以管理员身份运行
Loop A_Args.Length  ; For each parameter:
  {
    param := %A_Index%  ; Fetch the contents of the variable whose name is contained in A_Index.
    params .= A_Space . param
  }
; 在V2版本中A_IsUnicode已经被删除,默认就是Unicode
; V1版本判断代码
; ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA"
ShellExecute := "shell32\ShellExecute"
if not A_IsAdmin
{
    If A_IsCompiled
       DllCall(ShellExecute, "uint", 0, "str", "RunAs", "str", A_ScriptFull

同一个按键开始暂停(鼠标连点器)

F1::
	Sleep,300
	loop
	{
		Send,1{Click}
		Sleep,70
		if GetKeyState("F1")
		{
			break
		}
	}
return

AutoHotkey以管理员身份运行时,以普通用户权限运行程序

Run_AsUser(ProgramPath,arg) {
    ComObjCreate("Shell.Application")
    .Windows.FindWindowSW(0, 0, 0x08, 0, 0x01)  
    .Document.Application.ShellExecute(ProgramPath,arg) 
}

Autohotkey同一按键开关功能

    k :=0
    $%需要发送的热键%::   
    k := 1-k
    if (k == 1)
        settimer, Sendkey, %间隔时间%
    else
        settimer, Sendkey, off
    Return
   
    Sendkey:
    {
        send %需要发送的热键%
    }
    return

锁屏并熄灭屏幕

/*
  锁屏并熄灭屏幕
*/
LockAndOffScreen()
{
  Sleep 200
  Run rundll32.exe user32.dll`,LockWorkStation
  Sleep 200
  SendMessage,0x112,0xF170,2,,Program Manager
  Return
}

打开激活隐藏Chrome等软件

;Chrome等程序的窗口会存在N个子窗口。所以增加了寻找主窗口HWND的过程,就可以正常激活了。

hyf_onekeyWindow(exePath, titleClass := "", titleReg := "")
{ ;有些窗口用Ahk_exe exeName判断不准确,所以自定义个titleClass
    SplitPath, exePath, exeName, , , noExt
    If !hyf_processExist(exeName)
    {
        ;hyf_tooltip("启动中,请稍等...")
        Run,% exePath
        ;打开后自动运行 TODO
        funcName := noExt . "_runDo"
        If IsFunc(funcName)
        {
            ;hyf_tooltip("已自动执行函数:" . funcName)
            Func(funcName).Call()
        }

循环切换虚拟桌面

IniRead iniNum, switch-desktop.ini, Common, DesktopNum, 2

idx := 0
num := iniNum

#`::
if (num >= 2) {
  Send {Blind}{Ctrl down}
  if (idx >= num - 1) {
    while (idx > 0) {
      Send {Blind}{Left}
      idx--
      if (idx > 0)
        Sleep 100
    }
  } else {
    Send {Blind}{Right}
    idx++
  }
  Send {Blind}{Ctrl up}
}
return

#!`::
InputBox inputNum, Desktop number
num := inputNum
IniWrite % num, switch-desktop.ini, Common, DesktopNum
return

设置当前窗口置顶以及不被Win+D最小化

#Requires AutoHotkey v2.0
^+l::{
    WinSetAlwaysOnTop(-1, "A") ; 强制置顶窗口
    WinSetExStyle("^0x80","A") ; 设置窗口不被Win+D最小化
    return
}

增加当前词语到Rime自定义词库

; 添加选中的“短语 触发词”到Rime输入法自定义短语
RimeAppend( ){
    ClipSaved := ClipboardAll  ; 保存当前剪贴板内容
    Clipboard := ""            ; 清空剪贴板以便于接下来的操作
    Send, ^c                   ; 复制选中的文本
    ClipWait, 1                ; 等待剪贴板更新

    if (Clipboard != "")
    {       
      if (InStr(Clipboard, " "))    ; 使用正则表达式检查是否符合"aaa 空格 bbb"的形式
      {
          ; 将"空格"替换为"Tab"
          ModifiedText := StrReplace(Clipboard, " ", A_Tab)
          ; 追加结果到指定文件
          FileAppend, %ModifiedText%`n, D:\User

设置任意键为Hotstring的终止符


Loop
{
   Input ch, I L1 V
   HOTY = %HOT%
   HOT  =
}
;此处设置为你喜欢的终止符热键
!l::  
   If (Asc(A_PriorHotKey) = Asc(":") and HOTY <> "")
      Send % "{BS " StrLen(A_PriorHotKey)-5 "}" HOTY
Return
;rtfm替换为热字符串
; HOT = 替换为热字符串对应需要发送的字符。
:*B0:rtfm::
   HOT = read the fantastic manual
Return


禁止关闭按钮关闭时最小化当前窗口

#IfWinActive ahk_class Notepad2U
LButton::
Click Down
IfWinNotActive ahk_class Notepad2U
{
   KeyWait LButton
   Click Up
}
return

LButton Up::
CoordMode, Mouse, Screen
MouseGetPos, x, y
SendMessage, 0x84,, (x & 0xFFFF) | (y & 0xFFFF) << 16  ; WM_NCHITTEST
if (ErrorLevel = 20) ; close button
   WinMinimize, A
Click Up
return