Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Strings in DSA: Immutability, Character Codes and Patterns

First published on CodeKairo , where the figures in this lesson are animated step by step. In short: A string is a sequence of characters stored like an array, so its length and the character at any index are O(1) to read. In Java, Python and JavaScript strings are immutable: every change creates a new string, so appending in a loop costs O(n²) unless you use a StringBuilder or join a list. Most…

A string is composed of characters stored sequentially, similar to an array. Its length and the character at any position can be accessed in constant time, O(1). In Java, Python and JavaScript, strings are immutable, meaning any operation that appears to modify a string actually generates a new string. This behavior can lead to inefficient O(n²) performance when appending characters in a loop, unless a StringBuilder or list join is used.

String problems often involve counting characters, using two pointers, or applying a sliding window technique. As strings are essentially arrays of characters, understanding this fundamental structure is crucial for solving string-based problems efficiently.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Java Encapsulation and Abstraction

1. Introduction Encapsulation and Abstraction are two important principles of Object-Oriented Programming (OOP) in Java. Encapsulation protects an object's data by controlling access through methods.

  • Abstraction simplifies Java AI service architecture.
  • Hides implementation details, exposes essential functionality.
  • Enhances modularity and scalability in GenAI applications.

How Japan’s Car Giants Are Winning by Sharing and Why It Matters for Software

What Do Toyotas and Your Codebase Have in Common? When three of Japan’s biggest automakers, Toyota, Nissan, and Honda, say they’re going to start using the same steel specs and wire colors, you know…

  • Toyota, Nissan, and Honda standardize parts to streamline supply chain
  • Standardization in auto industry parallels need for shared code standards in software
  • Embracing standards saves time and resources for innovation

Day 12: +358 downloads yesterday

Yesterday: 8,813 combined downloads (+358) , with 1,187 to go to 10,000. plumber-linter: 2,739 (+167) hexlens: 1,815 (+7) environmental-peek: 1,789 (+170) react-dismiss: 1,358 (+3) @parasraju…

More from Monday 23 November →