Reverse String ii | LeetCode 541 | C++

preview_player
Показать описание


**** Best Books For Data Structures & Algorithms for Interviews:**********
*****************************************************************************

LeetCoe 541 | Reverse String - ii,
Facebook Coding Interview question,
google coding interview question,
leetcode,
Reverse String ii,
Reverse String ii c++,
Reverse String ii Java,
Reverse String ii python,
Reverse String ii solution,
541. Reverse String ii,

#Facebook #CodingInterview #LeetCode #JuneLeetCodingChallenge #Google #Amazon #ReverseString
Рекомендации по теме
Комментарии
Автор

I can't believe how can anyone provide this type of video without any cost..Thanku sooo much..I was finding this type of video but never find before..Fortunately i got that.Sooo happy

vikramjha
Автор

i cant understand how you take r=min(k, s.length)

harshsharma-bxuh
Автор

sir why are we taking (int)s.length() when we know length will always be a number?

rachna
Автор

Great video.Worth Watching for understanding this problem.

tamilguru
Автор

Thanks man. So simple and fluid explanation :)

omkarkulkarni
Автор

Sir please provide the python solution too, those are really helpful

taram
Автор

Sir k value is only 2 Or can be more than 2?

nobita
Автор

why is the start(left variable) shifted by 2*k instead of L = L + k??

devalmodi
Автор

Python code:
# O(N) time | O(N) space
class Solution(object):
def reverseStr(self, s, k):

# reverse chars between start and end
start = 0
end = min(len(s), start+k)
s_list = list(s)

# advance the pointers by 2k
while start < len(s):
s_list[start:start+k] = s_list[start:start+k][::-1]
start += 2*k
end += min(len(s), start+k)

return "".join(s_list)

rramnani