- 博客(5)
- 收藏
- 关注
原创 力扣200:岛屿数量
通过这道题学到了很多,下面是官方给出的三种解法,分别是深度优先遍历、广度优先遍历和并查集。 方法一:深度优先遍历 class Solution { private: void dfs(vector<vector<char>>& grid, int r, int c) { int nr = grid.size(); int nc = grid[0].size(); grid[r][c] = '0'; if
2021-10-21 15:41:02 94
原创 IEEE极限编程:Word Permutation
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef struct { string word; int index; }WordPermutation; bool cmp(WordPermutation a, WordPermutation b) { for (int i = 0; i < a.word.length()&&a..
2021-10-20 19:10:07 164
原创 力扣33:搜索旋转排序数组
力扣33:搜索旋转排序数组 复杂化二分法: class Solution { public: int search(vector<int>& nums, int target) { int n = (int)nums.size(); if (!n) { return -1; } if (n == 1) { return nums[0] == target ? 0 : -
2021-10-20 19:04:34 76
原创 IEEE极限编程练习:Sorting Partition
题目描述: 自己上来第一反应还是暴力法,思路不够开阔找不到其他好的方法,下面是一位大神的做法: #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long sum = 0, etalon_sum = 0; int ans = 0; vector <int> e; vector <long long>
2021-10-17 10:41:31 422
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人