This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<stdlib.h> | |
#define true 1 | |
#define false 0 | |
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct Node { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct Node { | |
int data; | |
struct Node * next; | |
} Node; | |
Node * createNode(int val){ | |
Node * temp = (Node *)malloc(sizeof(Node)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int findNthNode(Node *head, Node **nthNode, int n){ | |
if(!head) return 1; | |
int count = findNthNode(head->next, nthNode, n); | |
//If we have unstack n calls from stack | |
if(count == n){ | |
*nthNode = head; | |
return ++count; | |
} | |
return ++count; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct Node { | |
int data; | |
struct Node * next; | |
} Node; | |
Node * createNode(int val){ | |
Node * temp = (Node *)malloc(sizeof(Node)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct Node { | |
int data; | |
struct Node * next; | |
} Node; | |
Node * createNode(int val){ | |
Node * temp = (Node *)malloc(sizeof(Node)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct Node { | |
int data; | |
struct Node * next; | |
} Node; | |
Node * createNode(int val){ | |
Node * temp = (Node *)malloc(sizeof(Node)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct Node { | |
int data; | |
struct Node *next; | |
} Node; | |
Node * createNode(int val){ | |
Node *temp = (Node *)malloc(sizeof(Node)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct Node { | |
int data; | |
struct Node * next; | |
} Node; | |
Node * create_node(int val){ | |
Node * temp = (Node *)malloc(sizeof(Node)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct Node { | |
int data; | |
struct Node * next; | |
} Node; | |
Node * create_node(int val){ | |
Node * temp = (Node *)malloc(sizeof(Node)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Linked list passed :7->6->5->4->3->Null ===========| | |
Linked list passed :6->5->4->3->Null =========| | | |
Linked list passed :5->4->3->Null =======| | | | |
Linked list passed :4->3->Null ======| | | | | |
Linked list passed :3->Null ====| | | | | | |
Linked list passed :Null ===| | | | | | | |
Length returned : 0 <===| | | | | | | |
Length returned : 1 <======= | | | | | | |
Length returned : 2 <=============| | | | | |
Length returned : 3 <=================| | | |
NewerOlder