Brother You are doing awesome work for students like us please keep going. can you please do the problem 6. Zizag Conversion on leetcode. I will be thankful.
@unemployedcse35145 ай бұрын
awesome ❤
@akankshasonkar68465 ай бұрын
Nice solution Nikhil :)
@rdrahuldhiman196 ай бұрын
I hope your eye heals quickly
@nikoo286 ай бұрын
thanks a lot for the good wishes...the eye infection caused me some delay to publish videos. Thanks for being a viewer of my channel and your patience :)
@arupgope26763 ай бұрын
I solve it using 2 pointer
@hemanthcse16 ай бұрын
We can achieve this without using extra space like stack fun reversePrefixSolution3(word: String, ch: Char): String { val firstOccurrence = word.indexOf(ch) if (firstOccurrence == -1){ return word } val result = CharArray(word.length) for (i in 0..firstOccurrence){ result[i] = word[firstOccurrence-i] } for (i in (firstOccurrence+1) until word.length){ result[i] = word[i] } return String(result) } correct me if i am wrong
@nikoo286 ай бұрын
When you use the charArray it does take up extra O(n) space. So the time complexity remains the same
@anuragrawat43506 ай бұрын
int index = word.indexOf(ch) if(index != -1){ return new StringBuilder(word.substring(0,index+1).reverse).toString() + word(substring(index+1,word.length())); } return word;
@RameshGaridapuri6 ай бұрын
// Online C compiler to run C program online #include #include void swap(char *p, char *q) { int temp; while ( p < q) { temp = *p ; *p++ = *q; *q-- = temp; } } char * fun_ub(char arr[], char p , int len) { int i = 0 ; while ( arr[i]!= '\0') { if ( arr[i] == 'd') { swap( &arr[0], &arr[i]); break; } i++; } return arr; } int main() { char arr[] = "abcdefd"; char a = 'd'; int stl = strlen(arr)-1; char *p = fun_ub(arr, a , stl); printf("%s", p); }