Skip to content

Instantly share code, notes, and snippets.

View jitsceait's full-sized avatar

Sangar Jitendra jitsceait

View GitHub Profile
#include<stdio.h>
#include<stdlib.h>
#define true 1
#define false 0
#include <stdio.h>
#include <stdlib.h>
typedef struct Node {
#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));
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;
}
#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));
#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));
#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));
#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));
#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));
#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));
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 <=================| | |