File tree Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* *
2
+ * Definition for singly-linked list.
3
+ * struct ListNode {
4
+ * int val;
5
+ * ListNode *next;
6
+ * ListNode(int x) : val(x), next(NULL) {}
7
+ * };
8
+ */
9
+ class Solution {
10
+ public:
11
+ bool hasCycle (ListNode *head)
12
+ {
13
+ if (head==NULL )
14
+ {
15
+ return false ;
16
+ }
17
+ ListNode* slow = head;
18
+ ListNode* fast = head;
19
+ while (fast!=NULL && fast->next !=NULL )
20
+ {
21
+ slow = slow->next ;
22
+ fast = fast->next ->next ;
23
+ if (fast==slow)
24
+ {
25
+ return true ;
26
+ }
27
+ }
28
+ return false ;
29
+ }
30
+ };
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ using namespace std ;
3
+
4
+ int main ()
5
+ {
6
+ string string1 = " comiccomedy" ;
7
+ int count = 0 ;
8
+ for (int i = 0 ;i<string1.length ();i++)
9
+ {
10
+ bool flag = true ;
11
+ for (int j = 0 ;j<string1.length ();j++)
12
+ {
13
+ if (i==j)
14
+ {
15
+ continue ;
16
+ }
17
+ if (string1[i]==string1[j])
18
+ {
19
+ flag = false ;
20
+ }
21
+ }
22
+ if (flag)
23
+ {
24
+ count++;
25
+ }
26
+ }
27
+ cout<<count<<endl;
28
+ }
29
+
You can’t perform that action at this time.
0 commit comments