@@ -376,6 +376,46 @@ def get_vowels(string):
376
376
get_vowels(' foobar' ) # ['o', 'o', 'a']
377
377
get_vowels(' gym' ) # []
378
378
```
379
+
380
+ ### Length of Last Word in a string
381
+ This method gets the length of last word in a given string.
382
+ ```
383
+ def lengthOfLastWord(self, s: str) -> int:
384
+ if(s.split()):
385
+ lst=s.split()
386
+ last=lst[-1]
387
+ return len(last)
388
+ return 0
389
+ ```
390
+ ### Valid Palindrome
391
+ This method returns a bool value specifying whether a string is palindromic or not.
392
+ ```
393
+ def isPalindrome(self, s: str) -> bool:
394
+ s = [ x.lower() for x in s if x.isalnum() ]
395
+ return s == s[::-1]
396
+ ```
397
+ ### Check Lowercase
398
+ This method checks if a string is in lower case or not.
399
+ ```
400
+ def toLowerCase(self, str):
401
+ """
402
+ :type str: str
403
+ :rtype: str
404
+ """
405
+ return str.lower()
406
+ ```
407
+ ### Count Negatives in a sorted Matrix
408
+ This method returns the count of negative numbers in a sorted matrix.
409
+ ```
410
+ def countNegatives(self, grid: List[List[int]]) -> int:
411
+ count = 0
412
+ for num in grid:
413
+ for n in num:
414
+ if n < 0:
415
+ count += 1
416
+ return count
417
+ ```
418
+
379
419
### Write to file
380
420
This method takes in the `` name of file `` and `` content `` then write the content into the file. If the file doesn't exist then it creates the file.
381
421
``` python
0 commit comments