Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Week_01/id_10/LeetCode_20_10.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
bool isValid(char* s) {
int length = strlen(s);
char* temp = (char*)malloc(length);
int tail = 0;
for (int i = 0;i < length;i++) {
char value = s[i];
if (value == '(' || value == '{' || value == '[' ) {
temp[tail] = value;
tail++;
}
else {
if (tail == 0) {
return false;
}
char now = temp[tail - 1];
if ((now == '(' && value == ')') || (now == '{' && value == '}') || (now == '[' && value == ']')) {

}
else {
return false;
}
tail--;
}
}
if (tail != 0) {
return false;
}
return true;
}
36 changes: 36 additions & 0 deletions Week_01/id_10/LeetCode_83_10.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* deleteDuplicates(struct ListNode* head) {
if (head == NULL ||head->next == NULL) {
return head;
}
struct ListNode* p = head;
int value = p->val;
while(p->next != NULL) {
if(p->next->val == value) {
deleteNode(p);
}
//边界条件
if (p->next != NULL) {
if (p->next->val > value) {
p = p->next;
value = p->val;
}
}
}
return head;
}
//删除节点p的后继节点
void deleteNode(struct ListNode* p) {
struct ListNode* q;
if (p->next != NULL) {
q = p->next;
p->next = q->next;
q = NULL;
}
}
Loading