File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -146,8 +146,39 @@ public:
146
146
147
147
148
148
## 其他语言版本
149
+ C:
150
+ ```c
151
+ /**
152
+ * Definition for singly-linked list.
153
+ * struct ListNode {
154
+ * int val;
155
+ * struct ListNode *next;
156
+ * };
157
+ */
149
158
150
159
160
+ struct ListNode* removeElements(struct ListNode* head, int val){
161
+ typedef struct ListNode ListNode;
162
+ ListNode *shead;
163
+ shead = (ListNode *)malloc(sizeof(ListNode));
164
+ shead->next = head;
165
+ ListNode *cur = shead;
166
+ while(cur->next != NULL){
167
+ if (cur->next->val == val){
168
+ ListNode *tmp = cur->next;
169
+ cur->next = cur->next->next;
170
+ free(tmp);
171
+ }
172
+ else{
173
+ cur = cur->next;
174
+ }
175
+ }
176
+ head = shead->next;
177
+ free(shead);
178
+ return head;
179
+ }
180
+ ```
181
+
151
182
Java:
152
183
``` java
153
184
/**
You can’t perform that action at this time.
0 commit comments