Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/koushikghosh11/phpdbframework
PHPDbFramework: A PHP library for streamlined MySQL database operations, featuring secure connections, CRUD operations, password hashing, and error handling. Simplify database management with ease.
https://github.com/koushikghosh11/phpdbframework
mariadb-mysql mysql mysql-client mysql-connector php php-framework php7
Last synced: about 1 month ago
JSON representation
PHPDbFramework: A PHP library for streamlined MySQL database operations, featuring secure connections, CRUD operations, password hashing, and error handling. Simplify database management with ease.
- Host: GitHub
- URL: https://github.com/koushikghosh11/phpdbframework
- Owner: koushikghosh11
- License: mit
- Created: 2022-03-10T15:43:57.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-24T15:09:18.000Z (about 1 year ago)
- Last Synced: 2023-11-24T16:26:05.306Z (about 1 year ago)
- Topics: mariadb-mysql, mysql, mysql-client, mysql-connector, php, php-framework, php7
- Language: PHP
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Leetcode - 160 Intersection of Two Linked Lists Using Two Pointer:
We can use TwoPointerTwo PointerTwoPointer algorithm to find intersected node.
## Mathematics:
Consider the following Linked List(LL) Structure:`A-->B-->C-->D--|`
`...............|-->E-->F-->G`
`.......H-->L-->|`
Here, head of first LL is `A` and head of second LL is `H`
Both intersect at node `E`Let distance from node `A` to `D` is `x` and distance from node `H` to `L` is `y`.
Distance from node `E` to `G` is common and it is `z`.During first traversal of LL1 and LL2, they will cover distance:
for LL1 pointer --> `x+z`
for LL2 pointer --> `y+z`When the pointers inerchange their position in second traversal then distance covered till D and L are same :
for LL1 pointer --> `x+z+y`
for LL2 pointer --> `y+z+x`if they will intersect then there exist a node that is common.
## Complexity
- Time Complexity: O(n+m)O(n+m)O(n+m)
- Space Complexity: O(1)O(1)O(1)## Code: Java
```java
public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
ListNode node1 = headA, node2 = headB;
int count = 0; // maintain count of traversal
while(count<2){
if(node1==node2) return node1;
if(node1.next==null) ++count; // if no match after traversing twice then LL will not intersect.
node1 = node1.next==null?headB:node1.next;
node2 = node2.next==null?headA:node2.next;
}return null;
}
```