64,173
社区成员




33. 搜索旋转排序数组 - 力扣(LeetCode) (leetcode-cn.com)
int search(int* nums, int numsSize, int target){
int i,j=-2;
for (i=0;i<numsSize;i++){
if (nums[i]==target){
j=i;
}
}
if (j!=-2)
return j;
else
return -1;
}
81. 搜索旋转排序数组 II - 力扣(LeetCode) (leetcode-cn.com)
bool search(int* nums, int numsSize, int target){
for (int i=0;i<numsSize;i++){
if (nums[i]==target)
return true;
}
return false;
}
153. 寻找旋转排序数组中的最小值 - 力扣(LeetCode) (leetcode-cn.com)
int findMin(int* nums, int numsSize){
int low=0,high=numsSize-1;
while (low<high){
int mid=low+(high-low)/2;
if (nums[mid]<nums[high]){
high=mid;
}
else{
low=mid+1;
}
}
return nums[low];
}
70. 爬楼梯 - 力扣(LeetCode) (leetcode-cn.com)
int climbStairs(int n){
int f[100];
f[0]=f[1]=1;
for (int i=2;i<=n;i++){
f[i]=f[i-1]+f[i-2];
}
return f[n];
}
509. 斐波那契数 - 力扣(LeetCode) (leetcode-cn.com)
int fib(int n){
int f;
if (n==0)
f=0;
if (n==1)
f=1;
if (n>1)
f=fib(n-1)+fib(n-2);
return f;
}
1137. 第 N 个泰波那契数 - 力扣(LeetCode) (leetcode-cn.com)
int tribonacci(int n){
int f[38];
f[0]=0,f[1]=1,f[2]=1;
for (int i=0;i<=n-3;i++)
{
f[i+3]=f[i]+f[i+1]+f[i+2];
}
return f[n];
}
2006. 差的绝对值为 K 的数对数目 - 力扣(LeetCode) (leetcode-cn.com)
int countKDifference(int* nums, int numsSize, int k){
int count=0;
for (int i=0;i<numsSize;i++){
for (int j=i+1;j<numsSize;j++){
if (abs(nums[i]-nums[j])==k)
count++;
}
}
return count;
}
LCP 01. 猜数字 - 力扣(LeetCode) (leetcode-cn.com)
int game(int* guess, int guessSize, int* answer, int answerSize){
int count=0,i=0,j=0;
while (i<guessSize){
if (guess[i]==answer[j]){
count++;
}
i++;
j++;
}
return count;
}
LCP 06. 拿硬币 - 力扣(LeetCode) (leetcode-cn.com)
int minCount(int* coins, int coinsSize){
int ans=0;
for (int i=0;i<coinsSize;i++){
ans+=(coins[i]+1)/2;
}
return ans;
}