This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int x[100001]; | |
int y[100001]; | |
int flag[100001] = {0}; | |
int min(int a, int b) { | |
return a > b ? b : a; | |
}; | |
int abs(int x) { | |
return x > 0 ? x : -x; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function stackseq(input, s, output) { | |
if (input.length === 0 && s.length === 0) { | |
console.log(output); | |
} else { | |
if (input.length != 0) { | |
s.push(input.pop()); | |
stackseq(input, s, output); | |
input.push(s.pop()); | |
} | |
if (s.length != 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @synopsis 二分法搜索循环有序数组 | |
* | |
* @param s 要查找的数组 | |
* @param k 要查找的关键字 | |
* | |
* @returns 当 k 存在时返回 k 的下标,当 k 不存在时返回 -1 | |
*/ | |
var foo = function (s, k) { | |
var mid; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<stdlib.h> | |
int is_sorted(int *s, int n) { | |
int i; | |
for (i = 0;i < n - 1;i++) { | |
if (s[i] > s[i + 1]) | |
return 0; | |
} | |
return 1; |