-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Homework #267
Homework #267
Conversation
Good Job!!! @luopeisPython homework:
Numpy homework:
Pandas homework:
|
@luopeis |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Good Job!!! @luopeisPython homework:
Numpy homework:
Pandas homework:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Matplotlib数据可视化作业!
@luopeis |
Good Job!!! @luopeisPython homework:
Numpy homework:
Pandas homework:
|
@luopeis |
434 字符串中的单词数: class Solution {
public int countSegments(String s) {
// 接受一个字符串参数s并返回一个整数值。
String[] str = s.split(" ");// 这一行将字符串s按照空格进行分割,并将结果存储在一个字符串数组str中。根据空格将字符串划分为多个单词,并将这些单词存储在数组中。
int count = 0;
for (String s1 : str) {
if (!s1.equals("")) {
count++;
}
} // for循环和if计数
return count;
}
} 1869那种连续子字符串更长 class Solution {
public boolean checkZeroOnes(String s) {
int l = s.length(); // 获取字符串s的长度
int m = 0, resm = 0; // 记录连续的1的数量和最大连续1的数量
int n = 0, resn = 0; // 记录连续的0的数量和最大连续0的数量
for (int i = 0; i < l; i++) { // 遍历字符串s的每个字符
if (s.charAt(i) == '1') { // 如果当前字符为'1'
m++; // 1的计数增加
resm = Math.max(m, resm); // 更新最大连续1的数量
n = 0; // 0的计数重置为0
} else { // 如果当前字符不为'1',即为'0'
n++; // 0的计数增加
m = 0; // 1的计数重置为0
resn = Math.max(n, resn); // 更新最大连续0的数量
}
}
return resm > resn ? true : false; // 比较最大连续1的数量和最大连续0的数量,返回相应的布尔值
}
}
class Solution {
public boolean checkOnesSegment(String s) {
return !s.contains("01"); // 检查字符串s中是否包含"01",返回是否不包含的结果
}
}
class Solution {
public int peakIndexInMountainArray(int[] arr) {
for (int i = 1; i < arr.length - 1; i++) { // 遍历数组arr,从索引1开始到倒数第二个索引
if (arr[i] > arr[i + 1]) { // 如果当前元素大于下一个元素
return i; // 返回当前索引作为山峰的峰值索引
}
}
return -1; // 如果未找到山峰,返回-1表示未找到
}
} 162.寻找峰值 class Solution {
public:
int findPeakElement(vector<int>& nums) {
int len = nums.size(); // 获取数组nums的长度
for (int i = 1; i < len - 1; i++) { // 遍历数组,从索引1开始到倒数第二个索引
if (nums[i] > nums[i - 1] && nums[i] > nums[i + 1]) { // 如果当前元素大于前一个元素且大于后一个元素
return i; // 返回当前索引作为峰值索引
break; // 结束循环
}
}
if (nums[0] > nums[len - 1]) { // 如果第一个元素大于最后一个元素
return 0; // 返回第一个元素的索引作为峰值索引
}
return len - 1; // 返回最后一个元素的索引作为峰值索引
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luopeis
完成Python基础+拓展作业,Matplotlib数据可视化作业!
No description provided.