Logo Rui's Blog
  • Home
  • About
  • Skills
  • Experiences
  • Education
  • More
    Featured Posts Recent Posts
  • Posts
  • Notes
  • English
    English 简体中文
  • Dark Theme
    Light Theme Dark Theme System Theme
Logo Inverted Logo
  • Posts
  • Markdown Sample
  • Shortcodes Sample
  • Internship
    • MiniMind
  • LLM
    • LLM architecture
      • Encoder-only
  • Paper Reading
    • dLLM
    • YAN
  • Pytorch
  • Pytorch
  • Transformer
    • Tokenizer
    • Word Embedding
    • Model
      • LSTM
      • RNN
  • algorithm
    • Array
      • Binary Search
    • Backtracking
    • Binary Tree
    • Dyanmic Programming
      • Multi-dimensional Dynamic Programming
    • Graph Theory
    • Linked List
    • Two-pointers
      • Leetcode 27. Remove Element
      • Leetcode 541. Reverse String II
      • Leetcode 344. Reverse String
      • Sliding Window
Hero Image
Leetcode 541 - Reverse String II

Leetcode 541. Reverse String II Problem Link Problem Description Given a string s and an integer k, reverse the first k characters for every 2k characters counting from the start of the string. If there are fewer than k characters left, reverse all of them. If there are less than 2k but greater than or equal to k characters, reverse the first k characters and leave the other as original.

    Monday, January 19, 2026 | 2 minutes Read
    Hero Image
    Leetcode 344 - Reverse String

    Problem Link Problem Description Write a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the input array in-place with O(1) extra memory. Example 1: Input: s = [“h”,“e”,“l”,“l”,“o”] Output: [“o”,“l”,“l”,“e”,“h”] Example 2: Input: s = [“H”,“a”,“n”,“n”,“a”,“h”] Output: [“h”,“a”,“n”,“n”,“a”,“H”] Approach Opposite Direction Pointers: One pointer starts at the beginning, and the other starts at the end. Both pointers move inward simultaneously with the same step size until they cross each other (left > right), at which point the traversal ends.

      Monday, January 19, 2026 | 2 minutes Read
      Hero Image
      Leetcode 27 - Remove Element

      Problem Link Problem Description Given an array nums and a value val, you need to in-place remove all instances of that value and return the new length of the array. Do not use extra space for another array; you must do this by modifying the input array in-place with O(1) extra space. The order of elements can be changed. You do not need to consider the elements beyond the new length.

        Sunday, January 18, 2026 | 3 minutes Read
        Navigation
        • About
        • Skills
        • Experiences
        • Education
        • Featured Posts
        • Recent Posts
        Contact me:
        • ruig0401@gmail.com
        • low-hands
        • Rui
        • +1 5875886800

        Liability Notice: This theme is under MIT license. So, you can use it for non-commercial, commercial, or private uses. You can modify or distribute the theme without requiring any permission from the theme author. However, the theme author does not provide any warranty or takes any liability for any issue with the theme.


        Toha Theme Logo Toha
        © 2026 Copyright.
        Powered by Hugo Logo