We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 027fe9f commit 7bd3a12Copy full SHA for 7bd3a12
Number_Segments_String/SimpleSolution.py
@@ -0,0 +1,20 @@
1
+##==================================
2
+## Leetcode
3
+## Student: Vandit Jyotindra Gajjar
4
+## Year: 2020
5
+## Problem: 434
6
+## Problem Name: Number of Segments in a String
7
+##===================================
8
+#
9
+#Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.
10
11
+#Please note that the string does not contain any non-printable characters.
12
13
+#Example:
14
15
+#Input: "Hello, my name is John"
16
+#Output: 5
17
+class Solution:
18
+ def countSegments(self, s):
19
+ tmp = s.split() #Initialize tmp which is a list of the non-space characters
20
+ return len(tmp) #We return the length of the list which whill be the number of segments
0 commit comments