Skip to main content

Posts

Showing posts from October, 2022

https://leetcode.com/problems/merge-two-sorted-lists/submissions/ soultion in both c++ and JavaScript easy question if you know linked list

 Merge two linked list solution in c++ -------------------------------------------------------------------------------------------------------------------- c++ /**  * Definition for singly-linked list.  * struct ListNode {  *     int val;  *     ListNode *next;  *     ListNode() : val(0), next(nullptr) {}  *     ListNode(int x) : val(x), next(nullptr) {}  *     ListNode(int x, ListNode *next) : val(x), next(next) {}  * };  */ class Solution { public:     ListNode* mergeTwoLists(ListNode* list1, ListNode* list2) {         ListNode *tempNode=new ListNode(); //create a new node         ListNode *head=tempNode; //create a new head and assign new node to head         while(list1 && list2) //until list1 or list2 not null         {             ...

HOW TO CREATE SIDE SCROLLING AND INFINITE SCROLLING GAME COMPLETE CONCEPT CAN BE APPLIED TO ANY GAME ENGINE

so endless gaming is very popular these days especially on  mobile devices so how i can create a smooth game which would run at a constant framerate on a slower device is really a difficult task so lets try to break up the things into very small pieces. 1. infinite endless games are different from traditional side scrolling endless games they need many types of adjustment form example a side scrolling game required three major things one a camera a Player or actor and many objects (platforms,enemies,hurdles etc ) so basic concept of slide scrolling game is    

c++ code for Binary search Tree in a Generic Way

c++ code for Binary search Tree in a Generic Way  copy and paste the code in editor (c++) run #include <stdio.h> #include<iostream> #include<queue> using namespace std; template < typename T > class Node {   //can store any type of data private:   //genric data or store any type of data   T data;   //reference of left pointer   Node *left = nullptr;   //reference of right pointer   Node *right = nullptr; public:   Node ()   {   };   ~Node ()   {   };   //set data   Node (T _data)   {     data = _data;   }   //all setter and getter   void setLeftNode (Node * _left)   {     left = _left;   }   void setRightNode (Node * _right)   {     right = _right;   }   Node < T > *getLeftNode ()   {     return left;   }   Node < T > *getRightNode ()   {     return ...

https://leetcode.com/problems/merge-intervals/submissions/ (Merge Intervals)

 code :- just copy and paste ------------------------------------------- class Solution { public:          vector<vector<int>> merge(vector<vector<int>>& intervals) {         //sort the intervals first         if(intervals.size()<=1)         {             return intervals;         }         sort(intervals.begin(),intervals.end(),[](vector<int> &a,vector<int> &b){             return a[0]<b[0];         });                 //all overlapping intervals with non overlapping intervals would be here         vector<vector<int>> mergeintervals;                  vector<int> startInterval=intervals.at(0);    ...