Leetcode with dani – Telegram
Leetcode with dani
1.31K subscribers
196 photos
14 videos
56 files
240 links
Join us and let's tackle leet code questions together: improve your problem-solving skills
Preparing for coding interviews
learning new algorithms and data structures
connect with other coding enthusiasts
Download Telegram
Leetcode with dani
#leet_code_Q2 #Array #leet_code_169 #Majority_Element…
give me your ideas about this question. how can we solve it???
so let's tackle this question. so how can we know the element is maority element ,if it is the most frequent element in the array yea . so we can calculate each element freaquency by creating a dictionary like this my_dicti = {} for i in nums: if nums[i] in my_dict: my_dict[i] +=1 else: my_dict[i] = 1 and we can print the find the maximum frequent number in the dictionary and return it but there is also another efficient method to do it by declearing two variabes one to contain the number and the second to cotain it's occurence like this
nums = [1,2,3,4,5,4,4,3]
contain = nums[0]
occurence = 0
for i in nums:
if i == contain:
occurence += 1
else:
if occurence == 0:
contain = i
occurence =1
else:
occurence -= 1
557. Reverse Words in a String III Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
Example 1:

Input: s = "Let's take LeetCode contest"
Output: "s'teL ekat edoCteeL tsetnoc"
Example 2:

Input: s = "Mr Ding"
Output: "rM gniD" #leet_code_Q3 #String
👍2
9. Palindrom number #leet_code_Q4 #math #my_twopointer Given an integer x, return true if x is a
palindrome, and false otherwise.
Example 1:
Input: x = 121
Output: true
Explanation: 121 reads as 121 from left to right and from right to left.
Example 2:
Input: x = -121
Output: false
Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.
Example 3:
Input: x = 10
Output: false
Explanation: Reads 01 from right to left. Therefore it is not a palindrome.
Leetcode with dani
Palindrome number
share ur ides on the comment section
it is the first hard question to be solved by me 😁
🎉4👍1
if you are interested to learn python join this group Python
Forwarded from Gizeale Wondie
left = 0
x = str(x)
right = len(x)-1
while left<= right:
if x[left]!= x[right]:
return False
left+=1
right-=1
return True
Forwarded from F
x = str(x)
return x[::-1] == x
ምስጉን ነው በክፉዎች ምክር ያልሄደ፥ በኃጢአተኞችም መንገድ ያልቆመ፥ በዋዘኞችም ወንበር ያልተቀመጠ።
ነገር ግን በእግዚአ·በሔር ሕግ ደስ ይለዋል፥ ሕጉንም በቀንና በሌሊት ያስባል፡፡
እርሱም በውኃ ፈሳሾች ዳር እንደ ተተከለች፡ ፍሬዋን በየጊዜዋ እንደምትሰጥ፡ ቅጠልዋም እንደማይረግፍ ዛፍ ይሆናል፤ የሚሠራውም ሁሉ ይከናወንለታል።
ክፉዎች እንዲህ አይደሉም፡ ነገር ግን ነፋስ ጠርጎ እንደሚወስደው ትቢያ ናቸው... ስለዚህ ክፉዎች በፍርድ፥ ኃጢአተኞችም በጻድቃን ማኅበር አይቆሙም።
እግዚአብሔር የጻድቃንን መንገድ ያውቃልና፥ የክፉዎች መንገድ ግን ትጠፋለች።
9
I strongly recommend starting to do LeetCode questions as early as possible. Whether you use it in real life or not, many companies ask for this skill during technical interviews, and it's not likely to change anytime soon. So, do as many problems as you can. Thanks!
👍4💯2
Leetcode with dani pinned «I strongly recommend starting to do LeetCode questions as early as possible. Whether you use it in real life or not, many companies ask for this skill during technical interviews, and it's not likely to change anytime soon. So, do as many problems as you can.…»
It is really helpful if you want to learn python.