Intersection of Two Linked Lists
[Question]: Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null.
Data structure & algorithm using swift language.
[Question]: Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null.
[Question] Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list. The first node is considered odd, and the second node is even, and so on. You must solve the problem in O(1) extra space complexity and O(n) time complexity. Example 1: Input: head = [1,2,3,4,5] Output: [1,3,5,2,4]
[Question] Reverse Singly Link List using Iterative & Recursion approach.
[Question]: Given the head of a linked list, remove the nth node from the end of the list and return its head. Input: head = [1,2,3,4,5], n = 4 Output: [1,3,4,5] #Approach Two pointer Step: 1 Move fast pointer till countStep: 2 Increment fast pointer till we get fast?.next == nil if we got nil just remove mid pointer…
Here is example of Doubly Link list in swift
[Question]: You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list. The middle node of a linked list of size n is the ⌊n / 2⌋th node from the start using 0-based indexing, where ⌊x⌋ denotes the largest integer less than or equal to x.
[Question]: Design a HashSet without using any built-in hash table libraries. Implement MyHashSet class:
[Question]: In an array nums and an integer k, return the total number of subarrays whose sum equals to k. Example 1: Input: nums = [1,1,1], k = 2 Output: 2 Example 2: Input: nums = [1,2,3], k = 3 Output: 2
[Question]: You are given a string ‘str’ of lowercase alphabets and an integer’k’ .Your task is to return the count all the possible substrings that have exactly ‘k’ distinct characters.For example:‘str’ = abcad and ‘k’ = 2.We can see that the substrings {ab, bc, ca, ad} are the only substrings with 2 distinct characters. Therefore, …
Count number of substrings with exactly k distinct characters Read More »
[Question]: Convert given string into Integer with given condition Approach #2 Using Recursion Plain Atoi Solution