Posts

Showing posts from February, 2024

Today I have learned basic in python

Image
  What is Python basics? Python Basics is for people who want to learn Python programming—whether you are a complete beginner to programming, or a developer with experience in another language. What Are Python Raw Strings? What's the Zen of Python? Begin your Python journey with these beginner-friendly tutorials. Learn fundamental Python concepts to kickstart your career. Is Python a good language for beginners? Python is a popular general-purpose programming language. It is used in machine learning, web development, desktop applications, and many other fields. Fortunately for beginners, Python has a simple, easy-to-use syntax. This makes Python a great language to learn for beginners. Our Python tutorials will cover all the fundamental concepts of Python.

Today I have learned Basic portfolio in javascript

Image
 Basic portfolio in javascript: < div className = "row" style = { { margin : "0px" } } >             < div class = "col-lg-6 col-md-6 col-12" >                 < div className = "about1" >                     < h3 className = "login" >                         < br ></ br >                         < br ></ br >                         < br ></ br >                         < br ></ br >                     Hi Everyone, I am < spaN className = "about2" > Dhisha </ spaN > from < span class...

Today I have solved the problem in javascript

 You are given an N by N matrix of random letters and a dictionary of words. Find the maximum number of words that can be packed on the board from the given dictionary. A word is considered to be able to be packed on the board if: It can be found in the dictionary It can be constructed from untaken letters by other words found so far on the board The letters are adjacent to each other (vertically and horizontally, not diagonally). Each tile can be visited only once by any word. For example, given the following dictionary: { 'eat', 'rain', 'in', 'rat' } and matrix: [['e', 'a', 'n'],  ['t', 't', 'i'],  ['a', 'r', 'a']] Your function should return 3, since we can make the words 'eat', 'in', and 'rat' without them touching each other. We could have alternatively made 'eat' and 'rain', but that would be incorrect since that's only 2 words. const...

Today I have solved the problem in javascript

You are given a tree with an even number of nodes. Consider each connection between a parent and child node to be an "edge". You would like to remove some of these edges, such that the disconnected subtrees that remain each have an even number of nodes. For example, suppose your input was the following tree:    1   / \   2   3     / \     4   5  / | \ 6  7  8 In this case, removing the edge (3, 4) satisfies our requirement. Write a function that returns the maximum number of edges you can remove while still satisfying this requirement.  const tree = [     [1],     [0, 3],     [5],     [1, 4, 5],     [3],     [2, 3, 6, 7, 8],     [5],     [5],     [5] ]; const result = maxEdgesToRemove(tree); function maxEdgesToRemove(tree) {     const dfs = (node, parent, evenCount) => {       ...

Today I have learned Footer in javascript

Image
 Footer in javascript: Definition and Usage The  <footer>  tag defines a footer for a document or section. A  <footer>  element typically contains: authorship information copyright information contact information sitemap back to top links related documents You can have several  <footer>  elements in one document. Tips and Notes Tip:  Contact information inside a  <footer>  element should go inside an  <address>  tag. Copy your header and footer code to header.txt and footer.txt files and then just add this code to your JavaScript file. Don't forget to: include JavaScript file to those pages where you want to show header and footer. check path for header and footer txt files. You can also add header and footer code to separate JavaScript files as you like. import React , { Component } from "react" ; export default class Foot...

Today I have solved the problem in javascript

 You are given a string of length N and a parameter k. The string can be manipulated by taking one of the first k letters and moving it to the end. Write a program to determine the lexicographically smallest string that can be created after an unlimited number of moves. For example, suppose we are given the string daily and k = 1. The best we can create in this case is ailyd. const inputString = "daily"; const kValue = 1; const result = getLexicographicallySmallestString(inputString, kValue); function getLexicographicallySmallestString(s, k) {     let smallestString = s; for (let i = 1; i <= k; i++) {         let rotatedString = s.substring(i) + s.substring(0, i);         if (rotatedString < smallestString) {             smallestString = rotatedString;         } return smallestString; }console.log(result); Output: ailyd

Today I have solved the problem in javascript

 A ternary search tree is a trie-like data structure where each node may have up to three children. Here is an example which represents the words code, cob, be, ax, war, and we.        c     /  |  \    b   o   w  / |   |   | a  e   d   a |    / |   | \  x   b  e   r  e The tree is structured according to the following rules: left child nodes link to words lexicographically earlier than the parent prefix right child nodes link to words lexicographically later than the parent prefix middle child nodes continue the current word For instance, since code is the first word inserted in the tree, and cob lexicographically precedes cod, cob is represented as a left child extending from cod. Implement insertion and search functions for a ternary search tree. const tree = { root: null }; const words = ["code", "cob", "be...

Today I have sloved the problem in javascript

 Soundex is an algorithm used to categorize phonetically, such that two names that sound alike but are spelled differently have the same representation. Soundex maps every name to a string consisting of one letter and three numbers, like M460. One version of the algorithm is as follows:Remove consecutive consonants with the same sound (for example, change ck -> c). Keep the first letter. The remaining steps only apply to the rest of the string. Remove all vowels, including y, w, and h. Replace all consonants with the following digits: b, f, p, v -> 1 c, g, j, k, q, s, x, z -> 2 d, t -> 3 l -> 4 m, n -> 5 r -> 6If you don't have three numbers yet, append zeros until you do. Keep the first three numbers. Using this scheme, Jackson and Jaxen both map to J250.Implement Soundex function soundex(name) {     if (!name || typeof name !== 'string') {         return null;     } name = name.toUpperCase(); let result = name.charAt(0)...

Today I have learned Grid in javascript

Image
 Grid in javascript: Gone are the days when we have to use crazy tables and CSS hacks. Define a grid container and specify the number of columns in HTML CSS first. #grid { display: grid; grid-template-columns: repeat (2, auto); } Use Javascript to add cells to the grid container. Create cell as many cells as required and append them to the grid. Yep, it’s that simple. Below is an HTML code that defines the structure and styling of a webpage that displays an expanding card grid. The webpage uses the Flexbox layout module to create a responsive grid of cards that can be expanded or collapsed when clicked. The HTML document starts with the doctype declaration which specifies the version of HTML being used. Place it as a cover, make it full-width, inset images or use them as thumbnails. component, with advanced features and capabilities. Place the cards in a grid system, make them scrollable horizontally or create a tinder-like swipe away layout Javas...

Today I have solved the problem in javascript

 Write a program that determines the smallest number of perfect squares that sum up to N. Here are a few examples: Given N = 4, return 1 (4) Given N = 17, return 2 (16 + 1) Given N = 18, return 2 (9 + 9) function numSquares(N) {     const dp = new Array(N + 1).fill(Infinity);     dp[0] = 0;     for (let i = 1; i <= N; i++) {         for (let j = 1; j * j <= i; j++) {             dp[i] = Math.min(dp[i], dp[i - j * j] + 1);         }     }return dp[N]; } console.log(numSquares(4));  console.log(numSquares(17));  console.log(numSquares(18));  Output: 1 2 2

Today I have learned Local storage and Session storage in javascript

Image
 Local storage and Session storage: To view the data stored in the session storage in the web browser, you click the Application tab and select the Session Storage: The sessionStorage allows you to store the data for session only. The browser will delete the sessionStorage data when you close the browser tab or window. Format of storing data in SessionStorage and LocalStorage: Data must be stored in key-value pair in the SessionStorage and LocalStorage and key-value must be either number or string Here it can be seen that till we are inserting data in the form of string or number, we are able to get data correcrly! LocalStorage, sessionStorage Web storage objects  localStorage  and  sessionStorage  allow to save key/value pairs in the browser. What’s interesting about them is that the data survives a page refresh (for  sessionStorage ) and even a full browser restart (for  localStorage ). We’ll see that very soon. We already have cookies...