/**
* @param {string} s
* @return {number}
*/
var numSub = function(s) {
const MOD = 1_000_000_007; // Large prime for modulo operations
let ans = 0; // Final answer accumulator
let run = 0; // Current streak length of consecutive '1's
for (let i = 0; i < s.length; i++) {
if (s[i] === '1') {
run += 1; // Extend the current streak
ans = (ans + run) % MOD; // Add substrings ending at this position
# git gerrit客户端配置
## 客户端配置
- 安装 commit-msg hook,用于提交时生成Change-Id
```sh
curl -o .git/hooks/commit-msg \
http://gerrit-server:8080/tools/hooks/commit-msg
chmod +x .git/hooks/commit-msg
```
- 配置git review
```sh
# 安装 git-review
pip install git-review
# 或在项目目录配置
git config remote.origin.pushurl ssh://username@gerrit-server:29418/your-project
# 配置推送分支映射到远端refs/for/路径下以支持远端审核
git config remote.origin.push refs/heads/*:refs/for/*
```
## 验证本地是否配置正确
1.检查`.git/hooks`下是否存在`commit-msg`文件,且内容类似:
```sh
#!/b# swift语法注意事项:三元表达式
## 报错
```swift
print("【\(text)】---\((result? "匹配": "不匹配"))")
```
## 不报错
```swift
print("【\(text)】---\((result ? "匹配": "不匹配"))")
```
## 注意
**`三元运算符中?之前必须至少要有一个空格否则会和可选链语法冲突导致报错`**nest g controller [controllerName] [moduleNameForTheControlle]nest g module [modulename]/**
* @param {string} s
* @return {number}
*/
let numberOfSubstrings = function (s) {
const n = s.length;
// dp[i] stores the nearest index <= i where a '0' occurs
// (or -1 if none). This helps us quickly jump backwards
// to substrings that include more zeros.
const dp = Array(n + 1).fill(-1);
// Build the dp array
for (let i = 0; i < n; i++) {
if (i === 0 || s[i - 1] === '0') {
// If at start OR previous char was '0',
// mark cu// useFormHandler.js
import { ref } from 'vue'
export function useFormHandler(initialData = {}) {
const formData = ref({ ...initialData })
const errors = ref({})
const validate = () => {
errors.value = {}
Object.keys(formData.value).forEach(key => {
if (!formData.value[key]) errors.value[key] = 'Required'
})
return Object.keys(errors.value).length === 0
}
return { formData, errors, validate }
}
// ======================================= //
//npx shadcn@latest add @react-bits/MetallicPaint-TS-CSSnpx shadcn@latest add @react-bits/ElectricBorder-TS-CSSnpx shadcn@latest add @react-bits/GlitchText-TS-CSSnpx shadcn@latest add @react-bits/DecryptedText-TS-CSSnpx shadcn@latest add @react-bits/MagicBento-TS-CSSnpx shadcn@latest add @react-bits/Lightning-TS-CSS/**
* @param {number} n
* @param {number[][]} queries
* @return {number[][]}
*/
var rangeAddQueries = function(n, queries) {
// Step 1: Initialize an n x n matrix filled with 0s
let mat = Array.from({ length: n }, () => Array(n).fill(0));
// Step 2: Process each query
for (let [row1, col1, row2, col2] of queries) {
// Loop through the submatrix defined by the query
for (let r = row1; r <= row2; r++) {
for (let c = col1; c <= col2; c++) {
# Welcome to Cacher
We're delighted you've chosen Cacher to be your snippet organizer! Whether you're a solo developer or a member of your team, Cacher is here to help you organize and use snippets more efficiently.
Our users create snippets to:
- Remember project-specific algorithms
- Create cheatsheets for useful libraries
- Share knowledge with colleagues
Take a few minutes to look over our **Getting Started** snippets. To view more detailed information on features, you can visit [Cacher C:\Users\Administrator\AppData\Roaming\JetBrains\DataGrip2025.2\consoles