DEV Community

vishal.codes
vishal.codes

Posted on

Day 33/366

πŸš€ Today's Learning:

🌟 DSA

  • Reverse words in a given string
  • Longest common prefix

🌟 Dev

  • SSR vs CSR

πŸ” Some Key Highlights:

DSA

To reverse words in a given string, start by splitting the string into words. Then, iterate through the words in reverse order and append them to form the reversed string, ensuring to add spaces between words. Finally, return the reversed string. This process effectively flips the order of words while maintaining their individual characters' order within each word.

For finding the longest common prefix among an array of strings, first, set the prefix as the first string in the array. Then, iterate through the remaining strings and compare each character of the prefix with the corresponding character of the current string. If there's a mismatch or if the prefix length exceeds the length of the current string, trim the prefix accordingly. Repeat this process until the prefix is the longest common prefix among all strings in the array, then return the prefix.

DEV

Server-Side Rendering (SSR) involves rendering the web page on the server and sending a fully rendered page to the client. When a user requests a page, the server processes the request by executing the JavaScript code and generating the HTML content to be sent back to the browser. This approach provides faster initial load times and better SEO because search engine crawlers can easily parse the HTML content.

Client-Side Rendering (CSR), on the other hand, involves sending a minimal HTML document to the client, which includes links to JavaScript and CSS files. The browser then downloads these files and executes the JavaScript code to render the page dynamically. This approach provides a smoother and more interactive user experience, as the page can update without full page reloads. However, initial load times may be slower, and SEO can be more challenging since search engine crawlers may not execute JavaScript.

#100daysofcode #1percentplusplus #coding #dsa

Top comments (0)