repo_name stringlengths 5 122 | path stringlengths 3 232 | text stringlengths 6 1.05M |
|---|---|---|
smiley/ebpf-for-windows | libs/api/Verifier.h | <reponame>smiley/ebpf-for-windows
/*
* Copyright (c) Microsoft Corporation
* SPDX-License-Identifier: MIT
*/
#pragma once
#include "config.hpp"
#undef VOID
#include "platform.hpp"
#define VOID void
typedef int (*map_create_fp)(
uint32_t map_type, uint32_t key_size, uint32_t value_size, uint32_t max_entries, e... |
smiley/ebpf-for-windows | libs/platform/ebpf_program_types.c | /*
* Copyright (c) Microsoft Corporation
* SPDX-License-Identifier: MIT
*/
#include "ebpf_platform.h"
#include "ebpf_program_types_c.c"
ebpf_error_code_t
ebpf_program_information_encode(
const ebpf_program_information_t* program_information, uint8_t** buffer, unsigned long* buffer_size)
{
handle_t handl... |
smiley/ebpf-for-windows | tests/end_to_end/helpers.h | /*
* Copyright (c) Microsoft Corporation
* SPDX-License-Identifier: MIT
*/
#pragma once
#include "ebpf_api.h"
#include "ebpf_link.h"
#include "ebpf_platform.h"
typedef class _single_instance_hook
{
public:
_single_instance_hook()
{
ebpf_guid_create(&attach_type);
REQUIRE(
eb... |
kkarbowiak/cpp11-semaphore | semaphore.h | <gh_stars>0
/*
Copyright 2017 <NAME>
*/
#include <condition_variable>
#include <mutex>
namespace thr
{
template<typename C>
class semaphore
{
public:
semaphore();
explicit semaphore(C count);
void acquire();
void release();
private:
... |
charliewilliams/CWNotificationBanner | Example/Pods/Target Support Files/Pods-CWNotificationBanner_Example/Pods-CWNotificationBanner_Example-umbrella.h | #import <UIKit/UIKit.h>
FOUNDATION_EXPORT double Pods_CWNotificationBanner_ExampleVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_CWNotificationBanner_ExampleVersionString[];
|
charliewilliams/CWNotificationBanner | Example/Pods/Target Support Files/SwiftyTimer/SwiftyTimer-umbrella.h | <filename>Example/Pods/Target Support Files/SwiftyTimer/SwiftyTimer-umbrella.h
#import <UIKit/UIKit.h>
FOUNDATION_EXPORT double SwiftyTimerVersionNumber;
FOUNDATION_EXPORT const unsigned char SwiftyTimerVersionString[];
|
charliewilliams/CWNotificationBanner | Example/Pods/Target Support Files/CWNotificationBanner/CWNotificationBanner-umbrella.h | <reponame>charliewilliams/CWNotificationBanner<gh_stars>10-100
#import <UIKit/UIKit.h>
FOUNDATION_EXPORT double CWNotificationBannerVersionNumber;
FOUNDATION_EXPORT const unsigned char CWNotificationBannerVersionString[];
|
charliewilliams/CWNotificationBanner | Example/Pods/Target Support Files/Pods-CWNotificationBanner_Tests/Pods-CWNotificationBanner_Tests-umbrella.h | #import <UIKit/UIKit.h>
FOUNDATION_EXPORT double Pods_CWNotificationBanner_TestsVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_CWNotificationBanner_TestsVersionString[];
|
TemplateVoid/neoml | NeoMathEngine/src/CPU/x86/avx/src/BlobConvolution.h | /* Copyright © 2017-2020 ABBYY Production LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,... |
alokmenghrajani/ncipher_rust | demo/main.c | <reponame>alokmenghrajani/ncipher_rust
#include <stdio.h>
int rust_function(int);
int main(void) {
rust_function(10);
return 0;
}
|
bakercp/ofxIndexRange | libs/ofxIndexRange/include/ofx/IndexRange.h | <reponame>bakercp/ofxIndexRange
//
// Copyright (c) 2019 <NAME> <https://christopherbaker.net>
//
// SPDX-License-Identifier: MIT
//
#pragma once
#include <vector>
#include <iostream>
#include "json.hpp"
namespace ofx {
/// \brief An unsigned integral index range.
class IndexRange
{
public:
/// \brief Creat... |
bakercp/ofxIndexRange | libs/ofxIndexRange/include/ofx/IndexRangeList.h | <filename>libs/ofxIndexRange/include/ofx/IndexRangeList.h
//
// Copyright (c) 2019 <NAME> <https://christopherbaker.net>
//
// SPDX-License-Identifier: MIT
//
#pragma once
#include "ofx/IndexRange.h"
namespace ofx {
/// \brief A list for working with collections of index ranges.
///
/// Ranges can be added, ... |
BlackCatDevel0per/pyaesni | libaesni/include/iaesni.h | /*
* Copyright (c) 2010, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* thi... |
BlackCatDevel0per/pyaesni | pyaesni.c |
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <iaesni.h>
static PyObject *ige(PyObject *args, uint8_t encrypt) {
Py_buffer data, key, iv;
uint8_t *buf;
PyObject *out;
if (!PyArg_ParseTuple(args, "y*y*y*", &data, &key, &iv))
return NULL;
if (data.len == 0) {
PyErr_SetStri... |
BlackCatDevel0per/pyaesni | libaesni/test/test_libaesni.c | #include <iaesni.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Test vectors based on NIST Recommendation for Block Cipher Modes of Operation
// http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
unsigned char test_plain_text[64] = { 0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,... |
BlackCatDevel0per/pyaesni | libaesni/src/iaesni.c | /*
* Copyright (c) 2010, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* thi... |
BlackCatDevel0per/pyaesni | libaesni/src/iaes_asm_interface.h | <gh_stars>0
/*
* Copyright (c) 2010, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
... |
gaborcsardi/rim | Rig.app/Rig/rig-Bridging-Header.h | <reponame>gaborcsardi/rim
//
// rig-Bridging-Header.h
// Rig
//
// Created by <NAME> on 5/13/22.
//
#include "rig.h"
|
gaborcsardi/rim | Rig.app/Rig/rig.h | #include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int rig_last_error(char *ptr, size_t size);
int rig_get_default(char *ptr, size_t size);
int rig_list(char *ptr, size_t size);
int rig_list_with_versions(char *ptr, size_t size);
int rig_set_default(const char *ptr);
int rig_start_rs... |
ooooo-youwillsee/leetcode | 0239-Sliding-Window-Maximum/cpp_0239/Solution1.h | <filename>0239-Sliding-Window-Maximum/cpp_0239/Solution1.h
//
// Created by ooooo on 2019/11/1.
//
#ifndef CPP_0239_SOLUTION1_H
#define CPP_0239_SOLUTION1_H
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
class Solution {
public:
vector<int> maxSlidingWindow(vector<int> &nums, int k)... |
ooooo-youwillsee/leetcode | lcof_005/cpp_005/Solution1.h | //
// Created by ooooo on 2020/3/6.
//
#ifndef CPP_005__SOLUTION1_H_
#define CPP_005__SOLUTION1_H_
#include <iostream>
#include <sstream>
using namespace std;
class Solution {
public:
string replaceSpace(string s) {
stringstream ss;
for (auto &c: s) {
if (c == ' ') ss << "%20";
else ss << c;
... |
ooooo-youwillsee/leetcode | 0687-Longest-Univalue-Path/cpp_0687/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/4.
//
#ifndef CPP_0687_SOLUTION1_H
#define CPP_0687_SOLUTION1_H
#include "TreeNode.h"
class Solution {
public:
int ans = 0;
int dfs(TreeNode *node) {
if (!node)return 0;
int leftLen = dfs(node->left);
int rightLen ... |
ooooo-youwillsee/leetcode | lcof_018/cpp_018/Solution3.h | <reponame>ooooo-youwillsee/leetcode<filename>lcof_018/cpp_018/Solution3.h
//
// Created by ooooo on 2020/3/13.
//
#ifndef CPP_018__SOLUTION3_H_
#define CPP_018__SOLUTION3_H_
#include "ListNode.h"
/**
* recursion
*/
class Solution {
public:
ListNode *deleteNode(ListNode *head, int val) {
if (!head) return nul... |
ooooo-youwillsee/leetcode | 0518-Coin Change 2/cpp_0518/Solution3.h | /**
* @author ooooo
* @date 2021/2/17 19:23
*/
#ifndef CPP_0518__SOLUTION3_H_
#define CPP_0518__SOLUTION3_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int change(int amount, vector<int> &coins) {
int n = coins.size();
vector<int> dp(amount + 1, 0);
// 没有任何金币,可以组... |
ooooo-youwillsee/leetcode | 1863-Sum of All Subset XOR Totals/cpp_1863/Solution1.h | /**
*
* @author ooooo
* @date 2021/5/25 22:13
*/
#ifndef CPP_1863__SOLUTION1_H_
#define CPP_1863__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int ans = 0;
void dfs(vector<int> &nums, int i, int sum) {
ans += sum;
for (int j = i; j < nums.size(); j++)... |
ooooo-youwillsee/leetcode | 0767-Reorganize String/cpp_0767/Solution1.h | <filename>0767-Reorganize String/cpp_0767/Solution1.h<gh_stars>10-100
/**
* @author ooooo
* @date 2020/11/30 17:53
*/
#ifndef CPP_0767__SOLUTION1_H_
#define CPP_0767__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
class Solution {
public:
string reorganizeString(stri... |
ooooo-youwillsee/leetcode | 0933-Number-of-Recent-Calls/cpp_0933/Solution1.h | //
// Created by ooooo on 2020/1/5.
//
#ifndef CPP_0933_SOLUTION1_H
#define CPP_0933_SOLUTION1_H
#include <iostream>
#include <queue>
using namespace std;
class RecentCounter {
private:
queue<int> q;
public:
RecentCounter() {
}
int ping(int t) {
q.push(t);
while (!q.empty() && q.f... |
ooooo-youwillsee/leetcode | 0680-Valid-Palindrome-II/cpp_0680/Solution2.h | //
// Created by ooooo on 2020/1/28.
//
#ifndef CPP_0680__SOLUTION2_H_
#define CPP_0680__SOLUTION2_H_
#include <iostream>
using namespace std;
/**
* 递归
*/
class Solution {
public:
bool validPalindrome(string s, int left, int right, bool deleted) {
if (left >= right) return true;
if (s[left] == s[right]... |
ooooo-youwillsee/leetcode | lcof_014/cpp_014-1/Solution2.h | //
// Created by ooooo on 2020/3/11.
//
#ifndef CPP_014_1__SOLUTION2_H_
#define CPP_014_1__SOLUTION2_H_
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;
/**
* dp[n] = max( dp[1] * dp[n-1], dp[2] * dp[n-2] )
*
* dp[n] 表示绳子长度为 n
*/
class Solution {
public:
int cuttingRope(int... |
ooooo-youwillsee/leetcode | 0011-Container-With-Most-Water/cpp_0011/Solution1.h | //
// Created by ooooo on 2020/2/6.
//
#ifndef CPP_0011__SOLUTION1_H_
#define CPP_0011__SOLUTION1_H_
#include <iostream>
#include <vector>
/**
* 暴力破解
*/
using namespace std;
class Solution {
public:
int maxArea(vector<int> &height) {
int ans = 0;
for (int i = 0; i < height.size(); ++i) {
for (int ... |
ooooo-youwillsee/leetcode | 1688-Count of Matches in Tournament/cpp_1688/Solution1.h | /**
* @author ooooo
* @date 2020/12/15 20:21
*/
#ifndef CPP_1688__SOLUTION1_H_
#define CPP_1688__SOLUTION1_H_
#include <iostream>
using namespace std;
class Solution {
public:
int numberOfMatches(int n) {
if (n == 1) return 0;
return n / 2 + numberOfMatches((n + 1) / 2);
}
};
#endif //CPP_1688__SOLUTION1... |
ooooo-youwillsee/leetcode | 0021-Merge-Two-Sorted-Lists/cpp_0021/ListNode.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/23.
//
#ifndef CPP_0021__LISTNODE_H_
#define CPP_0021__LISTNODE_H_
#include <iostream>
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
#endif //CPP_0021__LISTNODE_H_
|
ooooo-youwillsee/leetcode | 0215-Kth-Largest-Element-in-an-Array/cpp_0215/Solution2.h | //
// Created by ooooo on 2020/2/20.
//
#ifndef CPP_0215__SOLUTION2_H_
#define CPP_0215__SOLUTION2_H_
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
/**
* heap
*/
class Solution {
public:
int findKthLargest(vector<int> &nums, int k) {
priority_queue<int, vector<int>, greater<int>... |
ooooo-youwillsee/leetcode | 0594-Longest-Harmonious-Subsequence/cpp_0594/Solution1.h | //
// Created by ooooo on 2020/1/12.
//
#ifndef CPP_0594__SOLUTION1_H_
#define CPP_0594__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
/**
* 哈希表
*/
class Solution {
public:
int findLHS(vector<int> &nums) {
int ans = 0;
unordered_map<int, int> m;
for... |
ooooo-youwillsee/leetcode | 0045-Jump Game II/cpp_0045/Solution1.h | <reponame>ooooo-youwillsee/leetcode
/**
* @author ooooo
* @date 2021/6/4 20:16
*/
#ifndef CPP_0045__SOLUTION1_H_
#define CPP_0045__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* 暴力dp
*/
class Solution {
public:
int jump(vector<int> &nums) {
int n = (int) nums.size();
vecto... |
ooooo-youwillsee/leetcode | 0290-Word-Pattern/cpp_0290/Solution1.h | //
// Created by ooooo on 2020/1/9.
//
#ifndef CPP_0290_SOLUTION1_H
#define CPP_0290_SOLUTION1_H
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;
class Solution {
public:
vector<string> split2(string s, string sep) {
vector<string> res;
int i = 0;
s += sep;
... |
ooooo-youwillsee/leetcode | 0061-Rotate List/cpp_0061/Solution1.h | /**
* @author ooooo
* @date 2020/10/5 18:03
*/
#ifndef CPP_0061__SOLUTION1_H_
#define CPP_0061__SOLUTION1_H_
#include "ListNode.h"
class Solution {
public:
ListNode *rotateRight(ListNode *head, int k) {
if (head == nullptr || k == 0) return head;
int len = 0;
ListNode * cur = head;
while (cur) {
cur... |
ooooo-youwillsee/leetcode | 0283-Move-Zeroes/cpp_0283/Solution2.h | <filename>0283-Move-Zeroes/cpp_0283/Solution2.h
//
// Created by ooooo on 2020/1/6.
//
#ifndef CPP_0283_SOLUTION2_H
#define CPP_0283_SOLUTION2_H
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
void moveZeroes(vector<int> &nums) {
if (nums.size() <= 1) return;
i... |
ooooo-youwillsee/leetcode | lcof_016/cpp_016/Solution3.h | //
// Created by ooooo on 2020/3/12.
//
#ifndef CPP_016__SOLUTION3_H_
#define CPP_016__SOLUTION3_H_
#include <iostream>
using namespace std;
/**
* o(logN)
*/
class Solution {
public:
double myPow(double x, int n) {
if (x == 0) return 0;
double ans = 1.0;
long b = n;
if (b < 0) {
x = 1 / x;... |
ooooo-youwillsee/leetcode | 0653-Two-Sum-IV-Input-is-a-BST/cpp_0653/Solution1.h | //
// Created by ooooo on 2020/1/3.
//
#ifndef CPP_0653_SOLUTION1_H
#define CPP_0653_SOLUTION1_H
#include "TreeNode.h"
#include <unordered_set>
class Solution {
public:
bool dfs(TreeNode *node, unordered_set<int> &s, int k) {
if (!node) return false;
if (s.count(k - node->val)) return true;
... |
ooooo-youwillsee/leetcode | 0075-Sort-Colors/cpp_0075/Solution1.h | //
// Created by ooooo on 2020/2/14.
//
#ifndef CPP_0075__SOLUTION1_H_
#define CPP_0075__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* 计数
*/
class Solution {
public:
void fill(vector<int> &nums, int start, int v, int count) {
for (int i = start, c = 0; c < count; ++i, c++) {... |
ooooo-youwillsee/leetcode | 0560-Subarray Sum Equals K/cpp_0560/Solution1.h | <gh_stars>10-100
//
// Created by ooooo on 6/2/2021.
//
#ifndef CPP_0560_SOLUTION1_H
#define CPP_0560_SOLUTION1_H
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Solution {
public:
int subarraySum(vector<int>& nums, int k) {
unordered_map<int, int> m;
m[0] =... |
ooooo-youwillsee/leetcode | lcof_032-3/cpp_032-3/Solution2.h | <reponame>ooooo-youwillsee/leetcode<gh_stars>10-100
//
// Created by ooooo on 2020/3/21.
//
#ifndef CPP_032_3__SOLUTION2_H_
#define CPP_032_3__SOLUTION2_H_
#include "TreeNode.h"
#include <queue>
/**
* dfs
*/
class Solution {
public:
void dfs(TreeNode *root, int level) {
if (!root) return;
if (ans.size()... |
ooooo-youwillsee/leetcode | 0788-Rotated-Digits/cpp_0788/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/30.
//
#ifndef CPP_0788__SOLUTION1_H_
#define CPP_0788__SOLUTION1_H_
#include <iostream>
#include <unordered_map>
using namespace std;
class Solution {
public:
unordered_map<int, int> map = {
{0, 0}, {1, 1}, {8, 8},
{2, 5}, {5, 2}, ... |
ooooo-youwillsee/leetcode | 0263-Ugly-Number/cpp_0263/Solution1.h | /**
* @author ooooo
* @date 2021/4/10 09:56
*/
#ifndef CPP_0263__SOLUTION1_H_
#define CPP_0263__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
bool isUgly(int n) {
if (n == 1) return true;
while (n > 1) {
if (n % 2 == 0) {
n /= 2;
} else if (n % ... |
ooooo-youwillsee/leetcode | 0111-Minimum-Depth-of-Binary-Tree/cpp_0111/Solution1.h | //
// Created by ooooo on 2019/11/4.
//
#ifndef CPP_0111_SOLUTION1_H
#define CPP_0111_SOLUTION1_H
#include "TreeNode.h"
class Solution {
private:
int min = 0;
void dfs(int level, TreeNode *node) {
if (!node) return;
if (!node->left && !node->right) {
if (min == 0) {
... |
ooooo-youwillsee/leetcode | 0434-Number of-Segments-in-a-String/cpp_0434/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/25.
//
#ifndef CPP_0434__SOLUTION1_H_
#define CPP_0434__SOLUTION1_H_
#include <iostream>
using namespace std;
class Solution {
public:
int countSegments(string s) {
s += " ";
int ans = 0, i = 0, j = s.find_first_of(" ", i);
while (j ... |
ooooo-youwillsee/leetcode | 0147-Insertion Sort List/cpp_0147/ListNode.h | <gh_stars>10-100
/**
* @author ooooo
* @date 2020/11/20 09:10
*/
#ifndef CPP_0147__LISTNODE_H_
#define CPP_0147__LISTNODE_H_
#include <iostream>
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
#endif //CPP_0147__LISTNODE_H_
|
ooooo-youwillsee/leetcode | 1800-Maximum Ascending Subarray Sum/cpp_1800/Solution1.h | /**
* @author ooooo
* @date 2021/3/28 12:17
*/
#ifndef CPP_1800__SOLUTION1_H_
#define CPP_1800__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <stack>
#include <numeric>
#include <queue>
using namespace std;
class Solution {
public... |
ooooo-youwillsee/leetcode | 0532-K-diff-Pairs-in-an-Array/cpp_0532/Solution1.h | //
// Created by ooooo on 2020/1/8.
//
#ifndef CPP_0532_SOLUTION1_H
#define CPP_0532_SOLUTION1_H
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
/**
* 暴力 超时
*/
class Solution {
public:
int findPairs(vector<int> &nums, int k) {
if (nums.empty()) return 0;
unor... |
ooooo-youwillsee/leetcode | 0127-Word-Ladder/cpp_0127/Solution3.h | <gh_stars>10-100
//
// Created by ooooo on 2019/12/31.
//
#ifndef CPP_0127_SOLUTION3_H
#define CPP_0127_SOLUTION3_H
#include <iostream>
#include <vector>
#include <unordered_set>
#include <queue>
using namespace std;
class Solution {
public:
int ladderLength(string beginWord, string endWord, vector<string> &wordLi... |
ooooo-youwillsee/leetcode | 1018-Binary Prefix Divisible By 5/cpp_1018/Solution1.h | <reponame>ooooo-youwillsee/leetcode
/**
* @author ooooo
* @date 2021/1/14 09:04
*/
#ifndef CPP_1018__SOLUTION1_H_
#define CPP_1018__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
// 101 -> 5
// 1010 -> 10
// 1111 -> 8 + 4 + 2 + 1 = 15
// 10100 -> 8 + 4 + 2 + 1 = 20
class Solution {
pu... |
ooooo-youwillsee/leetcode | 0189-Rotate-Array/cpp_0189/Solution1.h | <filename>0189-Rotate-Array/cpp_0189/Solution1.h
//
// Created by ooooo on 2019/12/5.
//
#ifndef CPP_0189_SOLUTION1_H
#define CPP_0189_SOLUTION1_H
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
// 每次移动一个, 总共k次
void rotate(vector<int> &nums, int k) {
if (nums.size... |
ooooo-youwillsee/leetcode | 0085-Maximal Rectangle/cpp_0085/Solution1.h | <reponame>ooooo-youwillsee/leetcode<gh_stars>10-100
/**
* @author ooooo
* @date 2020/12/26 11:24
*/
#ifndef CPP_0085__SOLUTION1_H_
#define CPP_0085__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int maximalRectangle(vector<vector<char>> &matrix) {
if (matri... |
ooooo-youwillsee/leetcode | 0061-Rotate List/cpp_0061/Solution2.h | /**
* @author ooooo
* @date 2020/10/5 20:07
*/
#ifndef CPP_0061__SOLUTION2_H_
#define CPP_0061__SOLUTION2_H_
#include "ListNode.h"
/**
* 先首尾相连
*/
class Solution {
public:
ListNode *rotateRight(ListNode *head, int k) {
if (head == nullptr || k == 0) return head;
int len = 1;
ListNode *cur = head;
whil... |
ooooo-youwillsee/leetcode | 0257-Binary-Tree-Paths/cpp_0257/Solution1.h | <filename>0257-Binary-Tree-Paths/cpp_0257/Solution1.h
//
// Created by ooooo on 2020/1/2.
//
#ifndef CPP_0257_SOLUTION1_H
#define CPP_0257_SOLUTION1_H
#include <vector>
#include <queue>
#include <unordered_map>
#include "TreeNode.h"
class Solution {
public:
vector<string> binaryTreePaths2(TreeNode *root) {
... |
ooooo-youwillsee/leetcode | lcof_063/cpp_063/Solution1.h | //
// Created by ooooo on 2020/4/24.
//
#ifndef CPP_063__SOLUTION1_H_
#define CPP_063__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int maxProfit(vector<int> &prices) {
int n = prices.size();
vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(2, v... |
ooooo-youwillsee/leetcode | 0876-Middle-of-the-Linked-List/cpp_0876/Solution2.h | <gh_stars>10-100
//
// Created by ooooo on 2020/1/23.
//
#ifndef CPP_0876__SOLUTION2_H_
#define CPP_0876__SOLUTION2_H_
#include "ListNode.h"
#include <vector>
/**
* 遍历数组存放
*/
class Solution {
public:
ListNode *middleNode(ListNode *head) {
vector<ListNode *> ans;
while (head) {
ans.push_back(head);
... |
ooooo-youwillsee/leetcode | lcof_016/cpp_016/Solution2.h | //
// Created by ooooo on 2020/3/12.
//
#ifndef CPP_016__SOLUTION2_H_
#define CPP_016__SOLUTION2_H_
#include <iostream>
using namespace std;
/**
* o(logN)
*/
class Solution {
public:
double help(double x, long n) {
if (n == 1) return x;
return n & 1 ? x * help(x * x, n / 2) : help(x * x, n / 2);
}
... |
ooooo-youwillsee/leetcode | lcof_027/cpp_027/Solution1.h | //
// Created by ooooo on 2020/3/17.
//
#ifndef CPP_027__SOLUTION1_H_
#define CPP_027__SOLUTION1_H_
#include "TreeNode.h"
class Solution {
public:
TreeNode *mirrorTree(TreeNode *root) {
if (!root)return root;
TreeNode *left = mirrorTree(root->left);
TreeNode *right = mirrorTree(root->right);
root-... |
ooooo-youwillsee/leetcode | 0551-Student-Attendance-Record-I/cpp_0551/Solution1.h | <gh_stars>10-100
//
// Created by ooooo on 2020/1/28.
//
#ifndef CPP_0551__SOLUTION1_H_
#define CPP_0551__SOLUTION1_H_
#include <iostream>
using namespace std;
class Solution {
public:
bool checkRecord(string s) {
int A_count = 0;
for (int i = 0; i < s.size(); ++i) {
if (s[i] == 'A') A_count++;
... |
ooooo-youwillsee/leetcode | 1312-Minimum Insertion Steps to Make a String Palindrome/cpp_1312/Solution1.h | /**
* @author ooooo
* @date 2020/10/4 21:18
*/
#ifndef CPP_1312__SOLUTION1_H_
#define CPP_1312__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int minInsertions(string s) {
int n = s.size();
vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));
for (int... |
ooooo-youwillsee/leetcode | lcof_011/cpp_011/Solution2.h | <gh_stars>10-100
//
// Created by ooooo on 2020/3/9.
//
#ifndef CPP_011__SOLUTION2_H_
#define CPP_011__SOLUTION2_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* O( log(n) )
*/
class Solution {
public:
int line_find(vector<int> &numbers, int l, int r) {
int ans = INT_MAX;
for (int i ... |
ooooo-youwillsee/leetcode | 0141-Linked-List-Cycle/cpp_0141/ListNode.h | <gh_stars>10-100
//
// Created by ooooo on 2019/10/30.
//
#ifndef CPP_0141_LISTNODE_H
#define CPP_0141_LISTNODE_H
#include <iostream>
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
#endif //CPP_0141_LISTNODE_H
|
ooooo-youwillsee/leetcode | 1309-Decrypt-String-from-Alphabet-to-Integer-Mapping/cpp_1309/Solution1.h | //
// Created by ooooo on 2020/2/3.
//
#ifndef CPP_1309__SOLUTION1_H_
#define CPP_1309__SOLUTION1_H_
#include <iostream>
#include <unordered_map>
#include <sstream>
using namespace std;
class Solution {
public:
string freqAlphabets(string s) {
unordered_map<string, char> m;
for (int i = 1; i <= 26; ++i) {... |
ooooo-youwillsee/leetcode | 0993-Cousins-in-Binary-Tree/cpp_0993/Solution2.h | //
// Created by ooooo on 2020/1/5.
//
#ifndef CPP_0993_SOLUTION2_H
#define CPP_0993_SOLUTION2_H
#include "TreeNode.h"
class Solution {
public:
int xDepth = 0, yDepth = 0;
TreeNode *xParent = nullptr, *yParent = nullptr;
int x, y;
void dfs(TreeNode *node, int depth, TreeNode *parent) {
if (!... |
ooooo-youwillsee/leetcode | 1647-Minimum Deletions to Make Character Frequencies Unique/cpp_1647/Solution1.h | /**
* @author ooooo
* @date 2021/2/28 13:04
*/
#ifndef CPP_1647__SOLUTION1_H_
#define CPP_1647__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;
class Solution {
public:
int minDeleti... |
ooooo-youwillsee/leetcode | 0392-Is-Subsequence/cpp_0392/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/18.
//
#ifndef CPP_0392__SOLUTION1_H_
#define CPP_0392__SOLUTION1_H_
#include <iostream>
using namespace std;
/**
* 暴力破解 double loop
*/
class Solution {
public:
bool isSubsequence(string s, string t) {
int ans = 0, i = 0;
for (auto &c:... |
ooooo-youwillsee/leetcode | 1237-Find-Positive-Integer-Solution-for-a-Given-Equation/cpp_1237/Solution2.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/22.
//
#ifndef CPP_1237__SOLUTION2_H_
#define CPP_1237__SOLUTION2_H_
#include "CustomFunction.h"
/**
* binary search
*/
class Solution {
public:
vector<vector<int>> findSolution(CustomFunction &customfunction, int z) {
vector<vector<int>> a... |
ooooo-youwillsee/leetcode | 0700-Search-in-a-Binary-Search-Tree/cpp_0700/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/5.
//
#ifndef CPP_0700_SOLUTION1_H
#define CPP_0700_SOLUTION1_H
#include "TreeNode.h"
class Solution {
public:
TreeNode *searchBST(TreeNode *root, int val) {
if (!root) return nullptr;
if (root->val < val) {
return s... |
ooooo-youwillsee/leetcode | 1700-Number of Students Unable to Eat Lunch/cpp_1700/Solution1.h | <reponame>ooooo-youwillsee/leetcode<filename>1700-Number of Students Unable to Eat Lunch/cpp_1700/Solution1.h
/**
* @author ooooo
* @date 2021/1/24 18:07
*/
#ifndef CPP_1700__SOLUTION1_H_
#define CPP_1700__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
... |
ooooo-youwillsee/leetcode | 0720-Longest-Word-in-Dictionary/cpp_0720/Solution3.h | <reponame>ooooo-youwillsee/leetcode<gh_stars>10-100
//
// Created by ooooo on 2020/1/14.
//
#ifndef CPP_0720__SOLUTION3_H_
#define CPP_0720__SOLUTION3_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
/**
* Trie
*/
class Solution {
private:
struct N... |
ooooo-youwillsee/leetcode | 0501-Find-Mode-in-Binary-Search-Tree/cpp_0501/Solution1.h | <gh_stars>10-100
//
// Created by ooooo on 2020/1/2.
//
#ifndef CPP_0501_SOLUTION1_H
#define CPP_0501_SOLUTION1_H
#include "TreeNode.h"
#include <vector>
#include <unordered_map>
class Solution {
public:
void dfs(TreeNode *node, unordered_map<int, int> &map, int &maxCount) {
if (!node) return;
i... |
ooooo-youwillsee/leetcode | lcof_055-1/cpp_055-1/Solution1.h | //
// Created by ooooo on 2020/4/11.
//
#ifndef CPP_055_1__SOLUTION1_H_
#define CPP_055_1__SOLUTION1_H_
#include "TreeNode.h"
#include <queue>
/**
* bfs
*/
class Solution {
public:
int maxDepth(TreeNode *root) {
if (!root) return 0;
queue<TreeNode *> q;
q.push(root);
int level = 0;
while (!q.... |
ooooo-youwillsee/leetcode | 0257-Binary-Tree-Paths/cpp_0257/Solution2.h | <gh_stars>10-100
//
// Created by ooooo on 2020/1/2.
//
#ifndef CPP_0257_SOLUTION2_H
#define CPP_0257_SOLUTION2_H
#include "TreeNode.h"
#include <vector>
class Solution {
public:
void help(TreeNode *node, string s, vector<string> &res) {
if (s == "") {
s = to_string(node->val);
} el... |
ooooo-youwillsee/leetcode | lcof_035/cpp_035/Solution2.h | <reponame>ooooo-youwillsee/leetcode<filename>lcof_035/cpp_035/Solution2.h
//
// Created by ooooo on 2020/3/22.
//
#ifndef CPP_035__SOLUTION2_H_
#define CPP_035__SOLUTION2_H_
#include "Node.h"
#include <unordered_map>
/**
* dfs
*/
class Solution {
public:
Node *copy(Node *node) {
if (!node) return nullptr;
... |
ooooo-youwillsee/leetcode | 0697-Degree of an Array/cpp_0697/Solution1.h | <reponame>ooooo-youwillsee/leetcode
/**
* @author ooooo
* @date 2021/2/20 09:36
*/
#ifndef CPP_0697__SOLUTION1_H_
#define CPP_0697__SOLUTION1_H_
#include <vector>
#include <iostream>
#include <unordered_map>
using namespace std;
class Solution {
public:
int findShortestSubArray(vector<int> &nums) {
// count... |
ooooo-youwillsee/leetcode | 0206-Reverse-Linked-List/cpp_0206/Solution1.h | <filename>0206-Reverse-Linked-List/cpp_0206/Solution1.h
//
// Created by ooooo on 2019/10/29.
//
#ifndef CPP_0206_SOLUTION1_H
#define CPP_0206_SOLUTION1_H
#include <iostream>
#include "ListNode.h"
using namespace std;
class Solution1 {
private:
public:
ListNode *reverseList(ListNode *head) {
ListNo... |
ooooo-youwillsee/leetcode | lcof_043/cpp_043/Solution2.h | <filename>lcof_043/cpp_043/Solution2.h
//
// Created by ooooo on 2020/3/28.
//
#ifndef CPP_043__SOLUTION2_H_
#define CPP_043__SOLUTION2_H_
#include <iostream>
#include <math.h>
using namespace std;
class Solution {
public:
int dfs(int n) {
if (n <= 0) return 0;
string s = to_string(n);
int high = s[0... |
ooooo-youwillsee/leetcode | lcof_049/cpp_049/Solution2.h | //
// Created by ooooo on 2020/4/6.
//
#ifndef CPP_049__SOLUTION2_H_
#define CPP_049__SOLUTION2_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* 把已经排好序的丑数 分别 *2,*3,*5,取最小的数,添加进数组中
*/
class Solution {
public:
int findMinValue(int count, vector<int> &nums, int num) {
for (int i = 0; i < co... |
ooooo-youwillsee/leetcode | 0031-Next-Permutation/cpp_0031/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/2/8.
//
#ifndef CPP_0031__SOLUTION1_H_
#define CPP_0031__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
void nextPermutation(vector<int> &nums) {
int i = nums.size() - 2;
while (i >= 0 && n... |
ooooo-youwillsee/leetcode | lcof_026/cpp_026/TreeNode.h | <filename>lcof_026/cpp_026/TreeNode.h
//
// Created by ooooo on 2020/3/17.
//
#ifndef CPP_026__TREENODE_H_
#define CPP_026__TREENODE_H_
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL),... |
ooooo-youwillsee/leetcode | 1641-Count Sorted Vowel Strings/cpp_1641/Solution1.h | <filename>1641-Count Sorted Vowel Strings/cpp_1641/Solution1.h
/**
* @author ooooo
* @date 2020/11/15 09:35
*/
#ifndef CPP_1641__SOLUTION1_H_
#define CPP_1641__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <numeric>
#inc... |
ooooo-youwillsee/leetcode | 0824-Goat-Latin/cpp_0824/SolutIon2.h | <reponame>ooooo-youwillsee/leetcode<filename>0824-Goat-Latin/cpp_0824/SolutIon2.h
//
// Created by ooooo on 2020/1/31.
//
#ifndef CPP_0824__SOLUTION2_H_
#define CPP_0824__SOLUTION2_H_
#include <iostream>
#include <sstream>
#include <unordered_set>
using namespace std;
/**
* 拼接字符串 使用stringstream
*/
class Solution {... |
ooooo-youwillsee/leetcode | 0019-Remove-Nth-Node-From-End-of-List/cpp_0019/Solution2.h | //
// Created by ooooo on 2020/2/8.
//
#ifndef CPP_0019__SOLUTION2_H_
#define CPP_0019__SOLUTION2_H_
#include "ListNode.h"
#include <vector>
/**
* 双指针, 其中一个先走n个,(如果有虚拟头指针,走n+1)
*/
class Solution {
public:
ListNode *removeNthFromEnd(ListNode *head, int n) {
ListNode *dummyNode = new ListNode(0), *cur = dummyN... |
ooooo-youwillsee/leetcode | 0070-Climbing-Stairs/cpp_0070/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2019/12/15.
//
#ifndef CPP_0070_SOLUTION1_H
#define CPP_0070_SOLUTION1_H
/**
* f(n) = f(n-1) + f(n-2)
*/
class Solution {
public:
int climbStairs(int n) {
if (n < 3)
return n;
int *res = new int[n + 1];
res[0] = 1;
... |
ooooo-youwillsee/leetcode | 0024-Swap-Nodes-in-Pairs/cpp_0024/Solution1.h | //
// Created by ooooo on 2019/10/30.
//
#ifndef CPP_0024_SOLUTION1_H
#define CPP_0024_SOLUTION1_H
#include <iostream>
#include "ListNode.h"
using namespace std;
class Solution {
public:
/**
* 给定 1->2->3->4, 你应该返回 2->1->4->3.
* @param head
* @return
*/
ListNode *swapPairs(ListNode *head... |
ooooo-youwillsee/leetcode | 0581-Shortest-Unsorted-Continuous-Subarray/cpp_0581/Solution1.h | //
// Created by ooooo on 2020/2/7.
//
#ifndef CPP_0581__SOLUTION1_H_
#define CPP_0581__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
/**
*双指针
*/
class Solution {
public:
int findUnsortedSubarray(vector<int> &nums) {
int left = 0, right = nums.size() - 1;
bool find_left = false... |
ooooo-youwillsee/leetcode | lcof_038/cpp_038/Solution1.h | //
// Created by ooooo on 2020/3/24.
//
#ifndef CPP_038__SOLUTION1_H_
#define CPP_038__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
class Solution {
public:
void dfs(string &str) {
if (str.size() == s.size()) {
str_set.insert(str);
return;
}... |
ooooo-youwillsee/leetcode | lcp-029/cpp_029/Solution1.h | <reponame>ooooo-youwillsee/leetcode
/**
* @author ooooo
* @date 2021/4/10 20:39
*/
#ifndef CPP_029__SOLUTION1_H_
#define CPP_029__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
typedef long long ll;
ll work(ll n, ll a, ll b) {
ll q = min(min(a, b), min(n - ... |
ooooo-youwillsee/leetcode | 0456-132 Pattern/cpp_0456/Solution1.h | <filename>0456-132 Pattern/cpp_0456/Solution1.h
/**
* @author ooooo
* @date 2021/3/24 16:32
*/
#ifndef CPP_0456__SOLUTION1_H_
#define CPP_0456__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <set>
using namespace std;
// o(nlogn)
class Solution {
public:
bool find132pattern(vector<int> &nums) {
... |
ooooo-youwillsee/leetcode | lcof_053-1/cpp_053-1/Solution3.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/4/9.
//
#ifndef CPP_053_1__SOLUTION3_H_
#define CPP_053_1__SOLUTION3_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int low_bound(vector<int> &nums, int target) {
int l = 0, r = nums.size() - 1;
whi... |
ooooo-youwillsee/leetcode | 0062-Unique-Paths/cpp_0062/Solution1.h | <filename>0062-Unique-Paths/cpp_0062/Solution1.h<gh_stars>10-100
//
// Created by ooooo on 2020/2/13.
//
#ifndef CPP_0062__SOLUTION1_H_
#define CPP_0062__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* dp[i][j] = dp[i][j-1] + dp[i-1][j]
*/
class Solution {
public:
// n 行 m 列
int ... |
ooooo-youwillsee/leetcode | 0523-Continuous Subarray Sum/cpp_0523/Solution1.h | //
// Created by ooooo on 6/2/2021.
//
#ifndef CPP_0523_SOLUTION1_H
#define CPP_0523_SOLUTION1_H
#include <iostream>
#include <unordered_set>
#include <vector>
using namespace std;
class Solution {
public:
bool checkSubarraySum(vector<int> &nums, int k) {
int n = nums.size();
if (n < 2) return false;
... |
ooooo-youwillsee/leetcode | 0438-Find-All-Anagrams-in-a-String/cpp_0438/Solution1.h | <reponame>ooooo-youwillsee/leetcode<filename>0438-Find-All-Anagrams-in-a-String/cpp_0438/Solution1.h
//
// Created by ooooo on 2020/3/1.
//
#ifndef CPP_0438__SOLUTION1_H_
#define CPP_0438__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
/**
* timeout
*/
class Soluti... |
ooooo-youwillsee/leetcode | 0589-N-ary-Tree-Preorder-Traversal/cpp_0589/Solution1.h | //
// Created by ooooo on 2020/1/3.
//
#ifndef CPP_0589_SOLUTION1_H
#define CPP_0589_SOLUTION1_H
#include "Node.h"
/**
* recursion
*/
class Solution {
public:
void help(Node *node, vector<int> &vec) {
if (!node) return;
vec.push_back(node->val);
for (auto child: node->children) {
... |
ooooo-youwillsee/leetcode | 0402-Remove K Digits/cpp_0402/Solution1.h | /**
* @author ooooo
* @date 2020/11/15 09:51
*/
#ifndef CPP_0402__SOLUTION1_H_
#define CPP_0402__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
string removeKdigits(string num, int k) {
if (k == num.size()) return "0";
vector<char> vec;
for (int i = 0; ... |
ooooo-youwillsee/leetcode | 0173-Binary Search Tree Iterator/cpp_0173/Solution1.h | <gh_stars>10-100
/**
* @author ooooo
* @date 2021/3/28 09:44
*/
#ifndef CPP_0173__SOLUTION1_H_
#define CPP_0173__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode() : val(0), left(nullptr), right(null... |
ooooo-youwillsee/leetcode | 0242-Valid-Anagram/cpp_0242/Solution1.h | <filename>0242-Valid-Anagram/cpp_0242/Solution1.h
//
// Created by ooooo on 2019/11/1.
//
#ifndef CPP_0242_SOLUTION1_H
#define CPP_0242_SOLUTION1_H
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
class Solution {
public:
bool isAnagram(string s, string t) {
sort(s.begin(),... |
ooooo-youwillsee/leetcode | 0216-Combination-Sum-III/cpp_0216/Solution1.h | /**
* @author ooooo
* @date 2020/9/11 11:27
*/
#ifndef CPP_0216__SOLUTION1_H_
#define CPP_0216__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
vector<vector<int>> ans;
void dfs(vector<int> &vec, int i, int k, int n) {
if (vec.size() == k) {
if (n == 0)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.