Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
••••••••••••••••••••
Intelligence View
⚡ tsecurity.de Intelligence

Reverse k Segments in Linked List

A few things come to mind after spending almost 24 hours working on this problem. When swapping elements in a linked list always follow these steps: Swapping distant from each other Update the values around the nodes…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

A few things come to mind after spending almost 24 hours working on this problem. When swapping elements in a linked list always follow these steps:






Swapping distant from each other




  1. Update the values around the nodes first

  2. Update the next pointers of each of the nodes to be swapped (a.next = b.next, b.next=temp.next — (temp = a))

  3. Update the prev pointers of each of the nodes to be swapped (a.prev=b.prev, b.prev=temp.prev — (temp=a))



This is crucial because doing this the wrong way will result in something called circular references where instead of the linked list be linear, it contains a node that ‘circles’ back to another node found earlier in the list.






Swapping nodes when both are next to each other



Instead of swapping nodes that are distant from each other, you can run into scenarios where the nodes are right next to each other. In this case:




  1. Update the values around the nodes first

  2. Update the next pointers of each of the nodes to be swapped (a.next = b.next, b.next=temp — (temp = a))

  3. Update the prev pointers of each of the nodes to be swapped (a.prev=b, b.prev=temp.prev — (temp=a))




/**
* Definition for singly-linked list.
* function ListNode(val, next) {
* this.val = (val===undefined ? 0 : val)
* this.next = (next===undefined ? null : next)
* }
*/

/**
* @param {ListNode} head
* @param {number} k
* @return {ListNode}
*/

var reverseKGroup = function(head, k) {
let length = 1
let node = head

if(k <= 1) return head

// get length and tail
while(node.next) {
node = node.next
length++
}
let tail = node

// doubly link
// get tail
let doublyNode = head
while(doublyNode.next) {
let prev = doublyNode
doublyNode = doublyNode.next
doublyNode.prev = prev
}
let segmentsAmt = Math.floor(length / k)
let currSegment = 0

const updateEnds = (a, b) => {
if(a === head) head = b
if(b === tail) tail = a
}

const reverse = (startSegment, k) => {
const sideSwap = (a, b) => {
if(a.prev) a.prev.next = b
if(b.next) b.next.prev = a

a.next = b.next
b.next = a

const temp = getTempNode(a)
a.prev = b
b.prev = temp.prev

updateEnds(a, b)
}

const swap = (a, b) => {
if(a.prev) a.prev.next = b
if(a.next) a.next.prev = b
if(b.next) b.next.prev = a
if(b.prev) b.prev.next = a

const temp = getTempNode(a)
a.next = b.next
b.next = temp.next

a.prev = b.prev
b.prev = temp.prev

updateEnds(a, b)
}

let needle = 0;
const kIdx = k - 1
while(needle < Math.floor(k/2)) {
const aIdx = (startSegment * k) + needle
const bIdx = (startSegment * k) + (kIdx - needle)
const a = nodeAtIdx(head, aIdx)
const b = nodeAtIdx(head, bIdx)
if(bIdx - aIdx === 1) {
sideSwap(a,b)
} else {
swap(a, b)
}
needle++
}
}

while(currSegment < segmentsAmt) {
reverse(currSegment, k)
currSegment++
}

return head
};

const nodeAtIdx = (head, idx) => {
let node = head
let i = 0;
while(i < idx) {
node = node.next
i++
}
return node
}

const getTempNode = (node) => {
const temp = new ListNode(node.val, node.next)
temp.prev = node.prev
return temp
}```



1. Sofort-Triage & Abwehrmaßnahmen

SOC Incident Playbook: Vulnerability Remediation & Verification
Syntax validiert (0 Fehler)
title: Detect Exploitation - Reverse k Segments in Linked List
id: 150fb82d-7c08-4fac-9e06-57d1b4d50536
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-25
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
Syntax validiert (0 Fehler)
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-25"
        description = "YARA Signature for "
    strings:
        $str = "Reverse k Segments in Linked L" ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("Reverse k Segments in Linked List")
| stats count earliest(_time) as first_seen latest(_time) as last_seen by src_ip, dest_ip, dest_host, signature
| eval first_seen=strftime(first_seen, "%Y-%m-%d %H:%M:%S"), last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count
Syntax validiert (0 Fehler)
message: "*Reverse k Segments in Linked List*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "Reverse k Segments in Linked List"
| summarize EventCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by SourceIP, DestinationIP, DestinationPort, Activity
| extend DetectionRule = "iShareStuff-CTI-Compiled"
| sort by EventCount desc

2. Cyber Threat Intelligence & Forensik

🎯
MITRE ATT&CK Matrix Navigator 14 Taktiken
Reconnaissance
-
Resource Development
-
Initial Access
Execution
Persistence
-
Privilege Escalation
Defense Evasion
Credential Access
-
Discovery
-
Lateral Movement
-
Collection
-
Command and Control
Exfiltration
-
Impact
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Reverse k Segments in Linked List.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Reverse k Segments in Linked List

Thematisch verwandte Begriffe: Reverse, Segments, Linked, List · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-87722 | Uncontrolled Resource Consumption (CWE-400 / CWE-1333) in regex search q…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel • Rechts: nächster Artikel • unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...
↗ Original-Quelle