This file contains 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
# Type a script or drag a script file from your workspace to insert its path. | |
export LC_CTYPE=en_US.UTF-8 | |
set -euo pipefail # 脚本只要发生错误,就终止执行 | |
# 删除DerivedData的build文件 | |
#echo $(dirname ${BUILD_DIR}) | |
rm -rf $(dirname ${BUILD_DIR}) | |
# 1. 环境配置,判断是否安装oclint,没有则安装 | |
if which oclint 2>/dev/null; then |
This file contains 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
rule-configurations: | |
- key: CYCLOMATIC_COMPLEXITY # Cyclomatic complexity of a method 10 | |
value: 30 | |
- key: LONG_LINE | |
value: 110 | |
- key: NCSS_METHOD # Number of non-commenting source statements of a method 30 | |
value: 50 | |
- key: LONG_VARIABLE_NAME | |
value: 40 | |
- key: NESTED_BLOCK_DEPTH |
This file contains 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
--- | |
# Language: ObjC | |
BasedOnStyle: Google | |
AccessModifierOffset: 0 | |
ConstructorInitializerIndentWidth: 4 | |
SortIncludes: false | |
# 连续赋值时,对齐所有等号 | |
# AlignConsecutiveAssignments: true | |
AlignAfterOpenBracket: true |
This file contains 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
@implementation UIImage (CornerRadius) | |
- (UIImage*)cornerWithRadius:(CGFloat)radius andSize:(CGSize)size{ | |
CGRect rect = CGRectMake(0, 0, size.width, size.height); | |
UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale); | |
CGContextRef ctx = UIGraphicsGetCurrentContext(); | |
UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(radius, radius)]; | |
CGContextAddPath(ctx,path.CGPath); | |
CGContextClip(ctx); |
This file contains 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
int removeDuplicates(int* nums, int numsSize) { | |
if (numsSize <= 0) { | |
return 0; | |
} | |
int j = 0; | |
for (int i = 1; i < numsSize; i++) { | |
if (nums[j] == nums[i]) | |
continue; | |
nums[++j] = nums[i]; | |
} |
This file contains 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
int maxProfit(int* prices, int pricesSize) { | |
if (pricesSize <= 0) { | |
return 0; | |
} | |
int profit = 0; | |
for (int i = 0; i < pricesSize-1; i ++) { | |
if (prices[i+1] > prices[i]) { | |
profit += prices[i+1] - prices[i]; | |
} |
This file contains 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
void rotate(int* nums, int numsSize, int k) { | |
if (k <= 0 || numsSize <= 0) { | |
return; | |
} | |
for (int i = 0; i < k; i++) { | |
int temp = nums[numsSize - 1]; | |
for (int j = numsSize - 1; j >= 1; j --) { | |
nums[j] = nums[j-1]; | |
} | |
nums[0] = temp; |
This file contains 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
// 4.存在重复 方法一暴力方法 | |
bool containsDuplicate(int* nums, int numsSize) { | |
if (numsSize <= 1) { | |
return false; | |
} | |
for (int i = 0; i < numsSize; i ++) { | |
for (int j = i+1; j < numsSize; j++) { | |
if (nums[i] == nums[j]) { | |
return true; | |
} |
This file contains 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
// 5.只出现一次的数字 | |
int singleNumber(int* nums, int numsSize) { | |
if (numsSize <= 0) { | |
return 0; | |
} | |
qsort(nums, numsSize, sizeof(nums[0]), cmp); | |
for (int i = 0; i < numsSize; i++) { | |
if (i == 0 && nums[i] != nums[i+1]) { | |
return nums[i]; | |
} else if (i == numsSize - 1 && nums[i-1] != nums[i]) { |
This file contains 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
// 6.加一 | |
int* plusOne(int* digits, int digitsSize, int* returnSize) { | |
if (digitsSize<=0) { | |
return digits; | |
} | |
int* ree =(int*)malloc((digitsSize)*sizeof(digits[0])); | |
for (int i = digitsSize-1; i >= 0; i--) { | |
if (digits[i] == 9) { | |
digits[i] = 0; | |
} else { |
NewerOlder