filmov
tv
LeetCode 344. Reverse String || Java Solution Walkthrough

Показать описание
LeetCode is a great platform for people who want general coding practice, whether that be for interviews or just wanting to practice their problem solving. I will be taking you through all the steps of finding the optimal solution to each problem on the site following a logical ordering setout by LeetCode themselves.
In this video, we are going over the problem 344. Reverse String and the goal is to take an array of characters given to us, and swap all the characters in a way which results in the string being reversed.
To solve this problem we could just create a whole new array and place the last index of s into the first index of the new array until we have read all the characters, but this would break the rule of modifying the array in place, and theres an even faster way of achieving this. To reverse a string, we only actually have to loop through half the string using a two pointer technique, where the first pointer starts at the beginning of the array, and the second pointer starts at the end of the array. You can swap the values at both pointers until they meet in the middle.
~~~ Stay Up To Date With My Social Media ~~~
#unknownkoder #leetcode #algorithms
In this video, we are going over the problem 344. Reverse String and the goal is to take an array of characters given to us, and swap all the characters in a way which results in the string being reversed.
To solve this problem we could just create a whole new array and place the last index of s into the first index of the new array until we have read all the characters, but this would break the rule of modifying the array in place, and theres an even faster way of achieving this. To reverse a string, we only actually have to loop through half the string using a two pointer technique, where the first pointer starts at the beginning of the array, and the second pointer starts at the end of the array. You can swap the values at both pointers until they meet in the middle.
~~~ Stay Up To Date With My Social Media ~~~
#unknownkoder #leetcode #algorithms