From 9b63dc45d3bc7fafc7ebf56052a81674ca0eb24b Mon Sep 17 00:00:00 2001 From: wolves Date: Fri, 27 Mar 2026 21:48:51 +0800 Subject: [PATCH] routine --- 26/03/169.go | 17 ++++++++++++ 26/03/2946.go | 31 ++++++++++++++++++++++ CLAUDE.md | 71 --------------------------------------------------- 3 files changed, 48 insertions(+), 71 deletions(-) create mode 100644 26/03/169.go create mode 100644 26/03/2946.go delete mode 100644 CLAUDE.md diff --git a/26/03/169.go b/26/03/169.go new file mode 100644 index 0000000..566b88f --- /dev/null +++ b/26/03/169.go @@ -0,0 +1,17 @@ +package main + +func majorityElement(nums []int) int { + a, s := nums[0], 1 + for i := 1; i < len(nums); i++ { + if a == nums[i] { + s++ + continue + } + s-- + if s == 0 { + a = nums[i] + s = 1 + } + } + return a +} diff --git a/26/03/2946.go b/26/03/2946.go new file mode 100644 index 0000000..ec697df --- /dev/null +++ b/26/03/2946.go @@ -0,0 +1,31 @@ +package main + +import "fmt" + +func areSimilar(mat [][]int, k int) bool { + lenX := len(mat) + lenY := len(mat[0]) + shift := k % lenY + + for i := 0; i < lenX; i++ { + for j := 0; j < lenY; j++ { + next := 0 + if i%2 == 0 { + next = (j + shift) % lenY + } else { + next = (j - shift + lenY) % lenY + } + if mat[i][j] != mat[i][next] { + return false + } + } + } + + return true +} + +func main() { + fmt.Println(areSimilar([][]int{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, 4)) + fmt.Println(areSimilar([][]int{{1, 2, 1, 2}, {5, 5, 5, 5}, {6, 3, 6, 3}}, 2)) + fmt.Println(areSimilar([][]int{{2, 2}, {2, 2}}, 3)) +} diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index bd689e3..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,71 +0,0 @@ -# CLAUDE.md - -This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. - -## Project Overview -This is a LeetCode solutions repository organized by date and problem type. The codebase contains solutions in multiple languages including C, C++, Go, and Java. The repository is structured with: -- Date-based directories (e.g., `23/04/`, `25/11/`) containing individual problem solutions -- Data structure implementations in the `dataStruct/` directory (LinkedList, Heap, Tree, etc.) -- Special categories like "dynamic planning" and "else" - -## Development Commands - -### Building and Running Code -Since this repository contains individual solution files rather than a unified project, compilation and execution is done per file: - -**For C/C++ files:** -```bash -# Compile C file -gcc -o solution filename.c - -# Compile C++ file -g++ -o solution filename.cpp - -# Run the compiled executable -./solution -``` - -**For Go files:** -```bash -# Run Go file directly -go run filename.go - -# Build Go executable -go build filename.go -``` - -**For Java files:** -```bash -# Compile Java file -javac filename.java - -# Run Java program -java filename -``` - -### Testing Solutions -There are no automated tests in this repository. Each solution should be tested manually by: -1. Compiling/running the solution file directly -2. Verifying output against expected LeetCode test cases -3. Using the data structure helper functions (like `list()`, `len()`, `creatRandomTree()`) for debugging - -## Code Architecture - -### Data Structures -The repository includes custom implementations of common data structures: -- **LinkedList**: Defined in `dataStruct/LinkedList/lists.h` with `ListNode` struct and utility functions (`createRandomList`, `list`, `array`, `len`) -- **Tree**: Defined in `dataStruct/Tree/Tree.h` with `TreeNode` struct and `creatRandomTree` function -- **Heap**: Basic template implementation in `dataStruct/Heap/Heap.h` -- **Queue**: Priority queue implementation in `dataStruct/Queue/PriorityQueue.c` - -### File Organization -- **Date directories**: Solutions organized by year/month (e.g., `25/11/` for November 2025) -- **Language variants**: Some problems have multiple language implementations (e.g., `3005.go`, `3005.cpp`, `3005.java`) -- **Utility headers**: Common tools and data structures in `tools.h` and the `dataStruct/` directory - -### Common Patterns -- Solutions often include debug output functions for visualizing data structures -- Random data generation functions are provided for testing (`createRandomList`, `creatRandomTree`) -- Header files use proper include guards and pragma once directives - -When working on new solutions, follow the existing patterns and place files in the appropriate date directory based on when the solution was created. \ No newline at end of file