diff --git a/docs/404.html b/docs/404.html index e171632..4969089 100644 --- a/docs/404.html +++ b/docs/404.html @@ -1 +1 @@ -404: This page could not be found

404

This page could not be found.

\ No newline at end of file +404: This page could not be found

404

This page could not be found.

\ No newline at end of file diff --git a/docs/_next/static/_VlBr_kOygObGgcBDgQ8x/_buildManifest.js b/docs/_next/static/IO84UVlTMRRUbweKGYE9P/_buildManifest.js similarity index 80% rename from docs/_next/static/_VlBr_kOygObGgcBDgQ8x/_buildManifest.js rename to docs/_next/static/IO84UVlTMRRUbweKGYE9P/_buildManifest.js index 111cae6..a337f86 100644 --- a/docs/_next/static/_VlBr_kOygObGgcBDgQ8x/_buildManifest.js +++ b/docs/_next/static/IO84UVlTMRRUbweKGYE9P/_buildManifest.js @@ -1 +1 @@ -self.__BUILD_MANIFEST=function(s,e,a,o,t,b){return{__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/":[s,"static/chunks/pages/index-de0ea15d1960934068dd.js"],"/_error":["static/chunks/pages/_error-a0e21b9b223f827fe1f2.js"],"/about":[s,"static/chunks/pages/about-69d6dd3f12016844b0b7.js"],"/blogs/algorithms":[s,e,a,o,t,b,"static/chunks/pages/blogs/algorithms-64cc8a79a4a314125cf9.js"],"/blogs/algorithms/big-o-notations":[s,e,a,t,"static/chunks/pages/blogs/algorithms/big-o-notations-bdd6ccb759dc2c4e4751.js"],"/blogs/data-structures":[s,e,a,o,t,b,"static/chunks/pages/blogs/data-structures-3e0b26b5b3edf34b6f79.js"],"/blogs/data-structures/stack":[s,e,a,"static/chunks/pages/blogs/data-structures/stack-b6dc47a1cf32b45fe917.js"],"/blogs/data-structures/tree":[s,e,a,"static/chunks/pages/blogs/data-structures/tree-916cf9135bdbe9a2b935.js"],"/blogs/html":[s,e,a,o,t,b,"static/chunks/pages/blogs/html-94a68e877b0741e522c9.js"],"/blogs/html/storage-api":[s,e,"static/chunks/pages/blogs/html/storage-api-1ce8d131310c2611a5f2.js"],"/blogs/js":[s,e,a,o,t,b,"static/chunks/pages/blogs/js-c72ee0c1dcb79d876aa2.js"],"/blogs/js/promises":[s,e,"static/chunks/pages/blogs/js/promises-6a1773c1ca5738397d37.js"],"/blogs/js/promises-part-2":[s,e,"static/chunks/pages/blogs/js/promises-part-2-59c155233663ff5c0fa1.js"],"/blogs/mobile":[s,e,a,o,t,b,"static/chunks/pages/blogs/mobile-e038540762a8781e2af4.js"],"/blogs/mobile/deep-link":[s,e,"static/chunks/pages/blogs/mobile/deep-link-adcfdf36d39a5c1dbf45.js"],"/blogs/performance":[s,e,a,o,t,b,"static/chunks/pages/blogs/performance-ca74bd3650f5d545d82a.js"],"/blogs/performance/optimize-web-bundles":[s,e,"static/chunks/pages/blogs/performance/optimize-web-bundles-8981031187ac30978b32.js"],"/blogs/problems":[s,e,a,o,t,b,"static/chunks/pages/blogs/problems-4b2d34fb808ea4d8dc3f.js"],"/blogs/problems/array-intersection":[s,e,a,"static/chunks/pages/blogs/problems/array-intersection-1035e124b6905b61ba39.js"],"/blogs/problems/facebook-passing-year-books":[s,e,a,"static/chunks/pages/blogs/problems/facebook-passing-year-books-e05a412d3482912f9de5.js"],"/blogs/problems/facebook-reverse-to-make-equal-array":[s,e,a,"static/chunks/pages/blogs/problems/facebook-reverse-to-make-equal-array-4969e5cc1f2d2c27ad5a.js"],"/blogs/problems/fibonacci":[s,e,a,o,"static/chunks/pages/blogs/problems/fibonacci-c4a11b80dd656dbd5de4.js"],"/blogs/problems/missing-element-in-permutation":[s,e,a,"static/chunks/pages/blogs/problems/missing-element-in-permutation-cb42fae86bdf6f3396d8.js"],"/blogs/problems/palindrome":[s,e,a,"static/chunks/pages/blogs/problems/palindrome-12436d8bac40b2b779d7.js"],"/blogs/problems/simple-frog-jump":[s,e,a,"static/chunks/pages/blogs/problems/simple-frog-jump-ef2f58ea09425a641df7.js"],"/blogs/problems/tape-equilibrium":[s,e,a,"static/chunks/pages/blogs/problems/tape-equilibrium-aac755806088be644ff1.js"],"/blogs/programming":[s,e,a,o,t,b,"static/chunks/pages/blogs/programming-630f0d4331ad229008e3.js"],"/blogs/programming/10-things-should-know":[s,e,"static/chunks/pages/blogs/programming/10-things-should-know-bf749c990a706e31041e.js"],"/blogs/react":[s,e,a,o,t,b,"static/chunks/pages/blogs/react-076693883c5bded17fae.js"],"/blogs/react/use-effect":[s,e,"static/chunks/pages/blogs/react/use-effect-839b8a16ccb3aa08f064.js"],"/blogs/security":[s,e,a,o,t,b,"static/chunks/pages/blogs/security-2bfe1fae43761686e3f9.js"],"/blogs/security/prevent-ssrf-attacks":[s,e,"static/chunks/pages/blogs/security/prevent-ssrf-attacks-e2d6a1c4c864f0a0d8b6.js"],"/coming-soon":[s,"static/chunks/pages/coming-soon-8452b69e0465342e6dd5.js"],sortedPages:["/","/_app","/_error","/about","/blogs/algorithms","/blogs/algorithms/big-o-notations","/blogs/data-structures","/blogs/data-structures/stack","/blogs/data-structures/tree","/blogs/html","/blogs/html/storage-api","/blogs/js","/blogs/js/promises","/blogs/js/promises-part-2","/blogs/mobile","/blogs/mobile/deep-link","/blogs/performance","/blogs/performance/optimize-web-bundles","/blogs/problems","/blogs/problems/array-intersection","/blogs/problems/facebook-passing-year-books","/blogs/problems/facebook-reverse-to-make-equal-array","/blogs/problems/fibonacci","/blogs/problems/missing-element-in-permutation","/blogs/problems/palindrome","/blogs/problems/simple-frog-jump","/blogs/problems/tape-equilibrium","/blogs/programming","/blogs/programming/10-things-should-know","/blogs/react","/blogs/react/use-effect","/blogs/security","/blogs/security/prevent-ssrf-attacks","/coming-soon"]}}("static/chunks/329-cd81a01206a495facbfb.js","static/chunks/358-aed3775a865b17a3f77d.js","static/chunks/638-4160c0bde2c3a538daf1.js","static/chunks/366-f71de40baace0cdcfa96.js","static/chunks/150-161084659dbbfdf9241f.js","static/chunks/369-ade5a919b84b4eb09814.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB(); \ No newline at end of file +self.__BUILD_MANIFEST=function(s,e,a,o,b,t){return{__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/":[s,"static/chunks/pages/index-de0ea15d1960934068dd.js"],"/_error":["static/chunks/pages/_error-a0e21b9b223f827fe1f2.js"],"/about":[s,"static/chunks/pages/about-69d6dd3f12016844b0b7.js"],"/blogs/algorithms":[s,e,a,o,b,t,"static/chunks/pages/blogs/algorithms-64cc8a79a4a314125cf9.js"],"/blogs/algorithms/big-o-notations":[s,e,a,b,"static/chunks/pages/blogs/algorithms/big-o-notations-bdd6ccb759dc2c4e4751.js"],"/blogs/data-structures":[s,e,a,o,b,t,"static/chunks/pages/blogs/data-structures-3e0b26b5b3edf34b6f79.js"],"/blogs/data-structures/stack":[s,e,a,"static/chunks/pages/blogs/data-structures/stack-04f2b3c45f285307c016.js"],"/blogs/data-structures/tree":[s,e,a,"static/chunks/pages/blogs/data-structures/tree-916cf9135bdbe9a2b935.js"],"/blogs/html":[s,e,a,o,b,t,"static/chunks/pages/blogs/html-94a68e877b0741e522c9.js"],"/blogs/html/storage-api":[s,e,"static/chunks/pages/blogs/html/storage-api-1ce8d131310c2611a5f2.js"],"/blogs/js":[s,e,a,o,b,t,"static/chunks/pages/blogs/js-c72ee0c1dcb79d876aa2.js"],"/blogs/js/promises":[s,e,"static/chunks/pages/blogs/js/promises-6a1773c1ca5738397d37.js"],"/blogs/js/promises-part-2":[s,e,"static/chunks/pages/blogs/js/promises-part-2-59c155233663ff5c0fa1.js"],"/blogs/mobile":[s,e,a,o,b,t,"static/chunks/pages/blogs/mobile-e038540762a8781e2af4.js"],"/blogs/mobile/deep-link":[s,e,"static/chunks/pages/blogs/mobile/deep-link-adcfdf36d39a5c1dbf45.js"],"/blogs/performance":[s,e,a,o,b,t,"static/chunks/pages/blogs/performance-ca74bd3650f5d545d82a.js"],"/blogs/performance/optimize-web-bundles":[s,e,"static/chunks/pages/blogs/performance/optimize-web-bundles-8981031187ac30978b32.js"],"/blogs/problems":[s,e,a,o,b,t,"static/chunks/pages/blogs/problems-4b2d34fb808ea4d8dc3f.js"],"/blogs/problems/array-intersection":[s,e,a,"static/chunks/pages/blogs/problems/array-intersection-1035e124b6905b61ba39.js"],"/blogs/problems/facebook-passing-year-books":[s,e,a,"static/chunks/pages/blogs/problems/facebook-passing-year-books-e05a412d3482912f9de5.js"],"/blogs/problems/facebook-reverse-to-make-equal-array":[s,e,a,"static/chunks/pages/blogs/problems/facebook-reverse-to-make-equal-array-4969e5cc1f2d2c27ad5a.js"],"/blogs/problems/fibonacci":[s,e,a,o,"static/chunks/pages/blogs/problems/fibonacci-c4a11b80dd656dbd5de4.js"],"/blogs/problems/missing-element-in-permutation":[s,e,a,"static/chunks/pages/blogs/problems/missing-element-in-permutation-cb42fae86bdf6f3396d8.js"],"/blogs/problems/palindrome":[s,e,a,"static/chunks/pages/blogs/problems/palindrome-12436d8bac40b2b779d7.js"],"/blogs/problems/simple-frog-jump":[s,e,a,"static/chunks/pages/blogs/problems/simple-frog-jump-ef2f58ea09425a641df7.js"],"/blogs/problems/tape-equilibrium":[s,e,a,"static/chunks/pages/blogs/problems/tape-equilibrium-aac755806088be644ff1.js"],"/blogs/programming":[s,e,a,o,b,t,"static/chunks/pages/blogs/programming-630f0d4331ad229008e3.js"],"/blogs/programming/10-things-should-know":[s,e,"static/chunks/pages/blogs/programming/10-things-should-know-bf749c990a706e31041e.js"],"/blogs/react":[s,e,a,o,b,t,"static/chunks/pages/blogs/react-076693883c5bded17fae.js"],"/blogs/react/use-effect":[s,e,"static/chunks/pages/blogs/react/use-effect-839b8a16ccb3aa08f064.js"],"/blogs/security":[s,e,a,o,b,t,"static/chunks/pages/blogs/security-2bfe1fae43761686e3f9.js"],"/blogs/security/prevent-ssrf-attacks":[s,e,"static/chunks/pages/blogs/security/prevent-ssrf-attacks-e2d6a1c4c864f0a0d8b6.js"],"/coming-soon":[s,"static/chunks/pages/coming-soon-8452b69e0465342e6dd5.js"],sortedPages:["/","/_app","/_error","/about","/blogs/algorithms","/blogs/algorithms/big-o-notations","/blogs/data-structures","/blogs/data-structures/stack","/blogs/data-structures/tree","/blogs/html","/blogs/html/storage-api","/blogs/js","/blogs/js/promises","/blogs/js/promises-part-2","/blogs/mobile","/blogs/mobile/deep-link","/blogs/performance","/blogs/performance/optimize-web-bundles","/blogs/problems","/blogs/problems/array-intersection","/blogs/problems/facebook-passing-year-books","/blogs/problems/facebook-reverse-to-make-equal-array","/blogs/problems/fibonacci","/blogs/problems/missing-element-in-permutation","/blogs/problems/palindrome","/blogs/problems/simple-frog-jump","/blogs/problems/tape-equilibrium","/blogs/programming","/blogs/programming/10-things-should-know","/blogs/react","/blogs/react/use-effect","/blogs/security","/blogs/security/prevent-ssrf-attacks","/coming-soon"]}}("static/chunks/329-cd81a01206a495facbfb.js","static/chunks/358-aed3775a865b17a3f77d.js","static/chunks/638-4160c0bde2c3a538daf1.js","static/chunks/366-f71de40baace0cdcfa96.js","static/chunks/150-161084659dbbfdf9241f.js","static/chunks/369-01a32bd2aed58c359a83.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB(); \ No newline at end of file diff --git a/docs/_next/static/_VlBr_kOygObGgcBDgQ8x/_ssgManifest.js b/docs/_next/static/IO84UVlTMRRUbweKGYE9P/_ssgManifest.js similarity index 100% rename from docs/_next/static/_VlBr_kOygObGgcBDgQ8x/_ssgManifest.js rename to docs/_next/static/IO84UVlTMRRUbweKGYE9P/_ssgManifest.js diff --git a/docs/_next/static/chunks/369-01a32bd2aed58c359a83.js b/docs/_next/static/chunks/369-01a32bd2aed58c359a83.js new file mode 100644 index 0000000..8952d4b --- /dev/null +++ b/docs/_next/static/chunks/369-01a32bd2aed58c359a83.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[369],{8145:function(t,e,n){"use strict";n.d(e,{Y:function(){return l}});var r=n(5893),a=n(5988),i=n(1664),o=n(7610),l=function(t){var e=t.type,n=t.post,l=n.link,s=n.module.meta,p="/blogs/".concat(e)+l;return(0,r.jsxs)("article",{className:"jsx-3233879758",children:[(0,r.jsx)(o.F,{meta:s,link:p}),(0,r.jsx)(i.default,{href:p,children:(0,r.jsx)("a",{className:"jsx-3233879758",children:"Read more \u2192"})}),(0,r.jsx)(a.default,{id:"3233879758",children:["article.jsx-3233879758{margin-bottom:3rem;}"]})]})}},3988:function(t,e,n){"use strict";function r(t){return t.keys().map((function(e){return{link:e.substr(1).replace(/\.mdx$/,""),module:t(e)}}))}n.d(e,{Lc:function(){return a},$F:function(){return i},R_:function(){return o},hx:function(){return l},TM:function(){return s},Di:function(){return p},yB:function(){return u},MC:function(){return m},qH:function(){return c},Bl:function(){return k}});var a=r(n(2900)),i=r(n(3735)),o=r(n(1304)),l=r(n(7312)),s=r(n(6126)),p=r(n(4417)),u=r(n(5501)),m=r(n(805)),c=r(n(1706)),k=r(n(6399))},2587:function(t,e,n){"use strict";n.r(e),n.d(e,{meta:function(){return m},default:function(){return d}});var r=n(6156),a=n(7375),i=(n(7294),n(4137)),o=n(2052),l=n(2919),s=(n(3042),n(9087));n(4070);function p(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function u(t){for(var e=1;e {\n storage[count] = value;\n count++;\n }\n const pop = () => {\n if(count === 0) {\n return undefined;\n }\n count--;\n const lastValue = storage[count];\n delete storage[count]\n return lastValue;\n }\n const size = () => {\n return count;\n }\n const peek = () => {\n return storage[count-1]\n }\n return {\n push,\n pop,\n size,\n peek\n }\n}\n"),(0,i.kt)("h2",null,(0,i.kt)(s.Z,{label:"Complexity Table",name:!0,mdxType:"AnchorLink"})),(0,i.kt)("p",null,"Below is the complexity table for Stack."),(0,i.kt)("hr",null),(0,i.kt)("table",null,(0,i.kt)("thead",{parentName:"table"},(0,i.kt)("tr",{parentName:"thead"},(0,i.kt)("th",u({parentName:"tr"},{align:null})),(0,i.kt)("th",u({parentName:"tr"},{align:"center"}),"Operation"),(0,i.kt)("th",u({parentName:"tr"},{align:"right"}),"Best"),(0,i.kt)("th",u({parentName:"tr"},{align:"right"}),"Average"),(0,i.kt)("th",u({parentName:"tr"},{align:"right"}),"Worst"))),(0,i.kt)("tbody",{parentName:"table"},(0,i.kt)("tr",{parentName:"tbody"},(0,i.kt)("td",u({parentName:"tr"},{align:null}),"1"),(0,i.kt)("td",u({parentName:"tr"},{align:"center"}),"Access"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"})),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,i.kt)("tr",{parentName:"tbody"},(0,i.kt)("td",u({parentName:"tr"},{align:null}),"2"),(0,i.kt)("td",u({parentName:"tr"},{align:"center"}),"Search"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"})),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,i.kt)("tr",{parentName:"tbody"},(0,i.kt)("td",u({parentName:"tr"},{align:null}),"3"),(0,i.kt)("td",u({parentName:"tr"},{align:"center"}),"Insertion"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"})),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,i.kt)("tr",{parentName:"tbody"},(0,i.kt)("td",u({parentName:"tr"},{align:null}),"4"),(0,i.kt)("td",u({parentName:"tr"},{align:"center"}),"Deletion"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"})),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,i.kt)("tr",{parentName:"tbody"},(0,i.kt)("td",u({parentName:"tr"},{align:null}),"5"),(0,i.kt)("td",u({parentName:"tr"},{align:"center"}),"Space Complexity"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"})),(0,i.kt)("td",u({parentName:"tr"},{align:"right"})),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")))),(0,i.kt)("hr",null),(0,i.kt)("h2",null,(0,i.kt)(s.Z,{label:"When do we use Stack",name:!0,mdxType:"AnchorLink"})),(0,i.kt)("p",null,"We can use it for this problems."),(0,i.kt)("h2",null,(0,i.kt)(s.Z,{label:"Real Time Problems",name:!0,mdxType:"AnchorLink"})),(0,i.kt)("p",null,"We can use it for this problems."),(0,i.kt)("h3",null,(0,i.kt)(s.Z,{label:"$Problem-1$",name:!0,mdxType:"AnchorLink"})),(0,i.kt)("p",null,"Below is the problem and its solution."),(0,i.kt)(l.Z,{mdxType:"CodeBlock"},"\nCode goes here...\n".trim()),(0,i.kt)("h2",null,(0,i.kt)(s.Z,{label:"Other Possible Questions",name:!0,mdxType:"AnchorLink"})),(0,i.kt)("p",null,"We can use it for this problems."),(0,i.kt)("h3",null,(0,i.kt)(s.Z,{label:"$Question-1$",name:!0,mdxType:"AnchorLink"})),(0,i.kt)("p",null,"Below is the Question and its solution."),(0,i.kt)(l.Z,{mdxType:"CodeBlock"},"\nCode goes here...\n".trim()))}d.isMDXComponent=!0},8440:function(t,e,n){"use strict";n.r(e),n.d(e,{meta:function(){return c},default:function(){return h}});var r=n(6156),a=n(7375),i=(n(7294),n(4137)),o=n(2052),l=n(2919),s=(n(3042),n(9087)),p=n(4070);function u(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function m(t){for(var e=1;e a -b);\n const sortedArray = arr.sort((a,b) => a -b);\n // Iterate Target Elements.\n for(let index = 0;index a + b, 0)\n return sumOfN - sumOfAll\n}\n"),(0,i.kt)("h2",null,(0,i.kt)(s.Z,{label:"Points to be Taken",name:!0,mdxType:"AnchorLink"})),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},"Array problem expect empty array condition check and single element check."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)(p.Z,{url:"https://en.wikipedia.org/wiki/Arithmetic_progression",mdxType:"ExternalLink"},"Arithmetic progression"))))}h.isMDXComponent=!0},103:function(t,e,n){"use strict";n.r(e),n.d(e,{meta:function(){return c},default:function(){return h}});var r=n(6156),a=n(7375),i=(n(7294),n(4137)),o=n(2052),l=n(2919),s=n(3042),p=n(9087);function u(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function m(t){for(var e=1;e {\n storage[count] = value;\n count++;\n }\n const pop = () => {\n if(count === 0) {\n return undefined;\n }\n count--;\n const lastValue = storage[count];\n delete storage[count]\n return lastValue;\n }\n const size = () => {\n return count;\n }\n const peek = () => {\n return storage[count-1]\n }\n return {\n push,\n pop,\n size,\n peek\n }\n}\n".trim()),(0,i.kt)("h2",null,(0,i.kt)(s.Z,{label:"Complexity Table",name:!0,mdxType:"AnchorLink"})),(0,i.kt)("p",null,"Below is the complexity table for Stack."),(0,i.kt)("hr",null),(0,i.kt)("table",null,(0,i.kt)("thead",{parentName:"table"},(0,i.kt)("tr",{parentName:"thead"},(0,i.kt)("th",u({parentName:"tr"},{align:null})),(0,i.kt)("th",u({parentName:"tr"},{align:"center"}),"Operation"),(0,i.kt)("th",u({parentName:"tr"},{align:"right"}),"Best"),(0,i.kt)("th",u({parentName:"tr"},{align:"right"}),"Average"),(0,i.kt)("th",u({parentName:"tr"},{align:"right"}),"Worst"))),(0,i.kt)("tbody",{parentName:"table"},(0,i.kt)("tr",{parentName:"tbody"},(0,i.kt)("td",u({parentName:"tr"},{align:null}),"1"),(0,i.kt)("td",u({parentName:"tr"},{align:"center"}),"Access"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"})),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,i.kt)("tr",{parentName:"tbody"},(0,i.kt)("td",u({parentName:"tr"},{align:null}),"2"),(0,i.kt)("td",u({parentName:"tr"},{align:"center"}),"Search"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"})),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,i.kt)("tr",{parentName:"tbody"},(0,i.kt)("td",u({parentName:"tr"},{align:null}),"3"),(0,i.kt)("td",u({parentName:"tr"},{align:"center"}),"Insertion"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"})),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,i.kt)("tr",{parentName:"tbody"},(0,i.kt)("td",u({parentName:"tr"},{align:null}),"4"),(0,i.kt)("td",u({parentName:"tr"},{align:"center"}),"Deletion"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"})),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,i.kt)("tr",{parentName:"tbody"},(0,i.kt)("td",u({parentName:"tr"},{align:null}),"5"),(0,i.kt)("td",u({parentName:"tr"},{align:"center"}),"Space Complexity"),(0,i.kt)("td",u({parentName:"tr"},{align:"right"})),(0,i.kt)("td",u({parentName:"tr"},{align:"right"})),(0,i.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")))),(0,i.kt)("hr",null),(0,i.kt)("h2",null,(0,i.kt)(s.Z,{label:"When do we use Stack",name:!0,mdxType:"AnchorLink"})),(0,i.kt)("p",null,"We can use it for this problems."),(0,i.kt)("h2",null,(0,i.kt)(s.Z,{label:"Real Time Problems",name:!0,mdxType:"AnchorLink"})),(0,i.kt)("p",null,"We can use it for this problems."),(0,i.kt)("h3",null,(0,i.kt)(s.Z,{label:"$Problem-1$",name:!0,mdxType:"AnchorLink"})),(0,i.kt)("p",null,"Below is the problem and its solution."),(0,i.kt)(l.Z,{mdxType:"CodeBlock"},"\nCode goes here...\n".trim()),(0,i.kt)("h2",null,(0,i.kt)(s.Z,{label:"Other Possible Questions",name:!0,mdxType:"AnchorLink"})),(0,i.kt)("p",null,"We can use it for this problems."),(0,i.kt)("h3",null,(0,i.kt)(s.Z,{label:"$Question-1$",name:!0,mdxType:"AnchorLink"})),(0,i.kt)("p",null,"Below is the Question and its solution."),(0,i.kt)(l.Z,{mdxType:"CodeBlock"},"\nCode goes here...\n".trim()))}d.isMDXComponent=!0},8440:function(t,e,n){"use strict";n.r(e),n.d(e,{meta:function(){return c},default:function(){return h}});var r=n(6156),a=n(7375),i=(n(7294),n(4137)),o=n(2052),l=n(2919),s=(n(3042),n(9087)),p=n(4070);function u(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function m(t){for(var e=1;e a -b);\n const sortedArray = arr.sort((a,b) => a -b);\n // Iterate Target Elements.\n for(let index = 0;index a + b, 0)\n return sumOfN - sumOfAll\n}\n"),(0,i.kt)("h2",null,(0,i.kt)(s.Z,{label:"Points to be Taken",name:!0,mdxType:"AnchorLink"})),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},"Array problem expect empty array condition check and single element check."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)(p.Z,{url:"https://en.wikipedia.org/wiki/Arithmetic_progression",mdxType:"ExternalLink"},"Arithmetic progression"))))}h.isMDXComponent=!0},103:function(t,e,n){"use strict";n.r(e),n.d(e,{meta:function(){return c},default:function(){return h}});var r=n(6156),a=n(7375),i=(n(7294),n(4137)),o=n(2052),l=n(2919),s=n(3042),p=n(9087);function u(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function m(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:"";return t?"/blogs/".concat(t):"/"},o=[{label:"Home",url:"/"},{label:"JavaScript",url:i("js")},{label:"HTML5",url:i("html")},{label:"React",url:i("react")},{label:"Programming",url:i("programming")},{label:"About",url:"/about"}];function s(){var t=(0,a.Z)(["\n width: 82%;\n margin-top: 35px;\n"]);return s=function(){return t},t}var c=n(9163).ZP.div(s());var u=function(t){var e=t.noStyle,n=void 0===e||e?c:l.Fragment;return(0,r.jsx)(n,{children:o.map((function(t,e){return(0,r.jsxs)("span",{children:[e>0&&" | ",(null===t||void 0===t?void 0:t.label)&&(0,r.jsx)("a",{href:null===t||void 0===t?void 0:t.url,children:null===t||void 0===t?void 0:t.label})]},null===t||void 0===t?void 0:t.label)}))})}},2587:function(t,e,n){"use strict";n.r(e),n.d(e,{meta:function(){return p},default:function(){return h}});var r=n(6156),a=n(7375),l=(n(7294),n(4137)),i=n(2052),o=n(2919),s=(n(3042),n(9087));n(4070);function c(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function u(t){for(var e=1;e {\n storage[count] = value;\n count++;\n }\n const pop = () => {\n if(count === 0) {\n return undefined;\n }\n count--;\n const lastValue = storage[count];\n delete storage[count]\n return lastValue;\n }\n const size = () => {\n return count;\n }\n const peek = () => {\n return storage[count-1]\n }\n return {\n push,\n pop,\n size,\n peek\n }\n}\n".trim()),(0,l.kt)("h2",null,(0,l.kt)(s.Z,{label:"Complexity Table",name:!0,mdxType:"AnchorLink"})),(0,l.kt)("p",null,"Below is the complexity table for Stack."),(0,l.kt)("hr",null),(0,l.kt)("table",null,(0,l.kt)("thead",{parentName:"table"},(0,l.kt)("tr",{parentName:"thead"},(0,l.kt)("th",u({parentName:"tr"},{align:null})),(0,l.kt)("th",u({parentName:"tr"},{align:"center"}),"Operation"),(0,l.kt)("th",u({parentName:"tr"},{align:"right"}),"Best"),(0,l.kt)("th",u({parentName:"tr"},{align:"right"}),"Average"),(0,l.kt)("th",u({parentName:"tr"},{align:"right"}),"Worst"))),(0,l.kt)("tbody",{parentName:"table"},(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",u({parentName:"tr"},{align:null}),"1"),(0,l.kt)("td",u({parentName:"tr"},{align:"center"}),"Access"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"})),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",u({parentName:"tr"},{align:null}),"2"),(0,l.kt)("td",u({parentName:"tr"},{align:"center"}),"Search"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"})),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",u({parentName:"tr"},{align:null}),"3"),(0,l.kt)("td",u({parentName:"tr"},{align:"center"}),"Insertion"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"})),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",u({parentName:"tr"},{align:null}),"4"),(0,l.kt)("td",u({parentName:"tr"},{align:"center"}),"Deletion"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"})),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",u({parentName:"tr"},{align:null}),"5"),(0,l.kt)("td",u({parentName:"tr"},{align:"center"}),"Space Complexity"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"})),(0,l.kt)("td",u({parentName:"tr"},{align:"right"})),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")))),(0,l.kt)("hr",null),(0,l.kt)("h2",null,(0,l.kt)(s.Z,{label:"When do we use Stack",name:!0,mdxType:"AnchorLink"})),(0,l.kt)("p",null,"We can use it for this problems."),(0,l.kt)("h2",null,(0,l.kt)(s.Z,{label:"Real Time Problems",name:!0,mdxType:"AnchorLink"})),(0,l.kt)("p",null,"We can use it for this problems."),(0,l.kt)("h3",null,(0,l.kt)(s.Z,{label:"$Problem-1$",name:!0,mdxType:"AnchorLink"})),(0,l.kt)("p",null,"Below is the problem and its solution."),(0,l.kt)(o.Z,{mdxType:"CodeBlock"},"\nCode goes here...\n".trim()),(0,l.kt)("h2",null,(0,l.kt)(s.Z,{label:"Other Possible Questions",name:!0,mdxType:"AnchorLink"})),(0,l.kt)("p",null,"We can use it for this problems."),(0,l.kt)("h3",null,(0,l.kt)(s.Z,{label:"$Question-1$",name:!0,mdxType:"AnchorLink"})),(0,l.kt)("p",null,"Below is the Question and its solution."),(0,l.kt)(o.Z,{mdxType:"CodeBlock"},"\nCode goes here...\n".trim()))}h.isMDXComponent=!0},2403:function(t,e,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/blogs/data-structures/stack",function(){return n(2587)}])}},function(t){t.O(0,[329,358,638,774,888,179],(function(){return e=2403,t(t.s=e);var e}));var e=t.O();_N_E=e}]); \ No newline at end of file +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[320],{4070:function(t,e,n){"use strict";var r=n(5893),a=(n(7294),{1:{notation:"Constant",value:"1"},"log log n":{notation:"Double Logarithmic",value:"Log Log n"},"log n":{notation:"Logarithmic",value:"Log n"},"\u221an":{notation:"Square Root",value:"\u221an"},n:{notation:"Linear",value:"n"},n2:{notation:"Quadratic",value:(0,r.jsxs)(r.Fragment,{children:["n",(0,r.jsx)("sup",{children:"2"})]})},"2n":{notation:"Exponential",value:(0,r.jsxs)(r.Fragment,{children:["2",(0,r.jsx)("sup",{children:"n"})]})},"n!":{notation:"Factorial",value:"n!"}});e.Z=function(t){var e=t.type,n=void 0===e?"time":e,l=t.value,i=t.children,o=a[l]||{},s=o.notation,c=o.value;return s?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("strong",{children:["time"===n?"Time Complexity":"Space Complexity",": "]}),"O(",c,") - ",s,i,(0,r.jsx)("br",{})]}):null}},2919:function(t,e,n){"use strict";n.d(e,{Z:function(){return j}});var r=n(5893),a=n(6156),l=(n(7294),n(2465)),i=n(9163);function o(){var t=(0,l.Z)(["\n display: table-cell;\n"]);return o=function(){return t},t}function s(){var t=(0,l.Z)(["\n display: table-cell;\n text-align: right;\n padding-right: 1em;\n user-select: none;\n opacity: 0.5;\n"]);return s=function(){return t},t}function c(){var t=(0,l.Z)(["\n display: table-row;\n"]);return c=function(){return t},t}function u(){var t=(0,l.Z)(["\n text-align: left;\n margin: 1em 0;\n padding: 0.5em;\n overflow: scroll;\n\n & .token-line {\n line-height: 1.3em;\n height: 1.3em;\n }\n"]);return u=function(){return t},t}function p(){var t=(0,l.Z)(["\n font-family: sans-serif;\n text-align: center;\n"]);return p=function(){return t},t}var m=i.ZP.div(p()),d=i.ZP.pre(u()),h=i.ZP.div(c()),k=i.ZP.span(s()),g=i.ZP.span(o()),f=n(9235),b=n(5424);function N(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function v(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:"";return t?"/blogs/".concat(t):"/"},o=[{label:"Home",url:"/"},{label:"JavaScript",url:i("js")},{label:"HTML5",url:i("html")},{label:"React",url:i("react")},{label:"Programming",url:i("programming")},{label:"About",url:"/about"}];function s(){var t=(0,a.Z)(["\n width: 82%;\n margin-top: 35px;\n"]);return s=function(){return t},t}var c=n(9163).ZP.div(s());var u=function(t){var e=t.noStyle,n=void 0===e||e?c:l.Fragment;return(0,r.jsx)(n,{children:o.map((function(t,e){return(0,r.jsxs)("span",{children:[e>0&&" | ",(null===t||void 0===t?void 0:t.label)&&(0,r.jsx)("a",{href:null===t||void 0===t?void 0:t.url,children:null===t||void 0===t?void 0:t.label})]},null===t||void 0===t?void 0:t.label)}))})}},2587:function(t,e,n){"use strict";n.r(e),n.d(e,{meta:function(){return p},default:function(){return h}});var r=n(6156),a=n(7375),l=(n(7294),n(4137)),i=n(2052),o=n(2919),s=(n(3042),n(9087));n(4070);function c(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function u(t){for(var e=1;e {\n storage[count] = value;\n count++;\n }\n const pop = () => {\n if(count === 0) {\n return undefined;\n }\n count--;\n const lastValue = storage[count];\n delete storage[count]\n return lastValue;\n }\n const size = () => {\n return count;\n }\n const peek = () => {\n return storage[count-1]\n }\n return {\n push,\n pop,\n size,\n peek\n }\n}\n"),(0,l.kt)("h2",null,(0,l.kt)(s.Z,{label:"Complexity Table",name:!0,mdxType:"AnchorLink"})),(0,l.kt)("p",null,"Below is the complexity table for Stack."),(0,l.kt)("hr",null),(0,l.kt)("table",null,(0,l.kt)("thead",{parentName:"table"},(0,l.kt)("tr",{parentName:"thead"},(0,l.kt)("th",u({parentName:"tr"},{align:null})),(0,l.kt)("th",u({parentName:"tr"},{align:"center"}),"Operation"),(0,l.kt)("th",u({parentName:"tr"},{align:"right"}),"Best"),(0,l.kt)("th",u({parentName:"tr"},{align:"right"}),"Average"),(0,l.kt)("th",u({parentName:"tr"},{align:"right"}),"Worst"))),(0,l.kt)("tbody",{parentName:"table"},(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",u({parentName:"tr"},{align:null}),"1"),(0,l.kt)("td",u({parentName:"tr"},{align:"center"}),"Access"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"})),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",u({parentName:"tr"},{align:null}),"2"),(0,l.kt)("td",u({parentName:"tr"},{align:"center"}),"Search"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"})),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",u({parentName:"tr"},{align:null}),"3"),(0,l.kt)("td",u({parentName:"tr"},{align:"center"}),"Insertion"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"})),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",u({parentName:"tr"},{align:null}),"4"),(0,l.kt)("td",u({parentName:"tr"},{align:"center"}),"Deletion"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"})),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",u({parentName:"tr"},{align:null}),"5"),(0,l.kt)("td",u({parentName:"tr"},{align:"center"}),"Space Complexity"),(0,l.kt)("td",u({parentName:"tr"},{align:"right"})),(0,l.kt)("td",u({parentName:"tr"},{align:"right"})),(0,l.kt)("td",u({parentName:"tr"},{align:"right"}),"O(n)")))),(0,l.kt)("hr",null),(0,l.kt)("h2",null,(0,l.kt)(s.Z,{label:"When do we use Stack",name:!0,mdxType:"AnchorLink"})),(0,l.kt)("p",null,"We can use it for this problems."),(0,l.kt)("h2",null,(0,l.kt)(s.Z,{label:"Real Time Problems",name:!0,mdxType:"AnchorLink"})),(0,l.kt)("p",null,"We can use it for this problems."),(0,l.kt)("h3",null,(0,l.kt)(s.Z,{label:"$Problem-1$",name:!0,mdxType:"AnchorLink"})),(0,l.kt)("p",null,"Below is the problem and its solution."),(0,l.kt)(o.Z,{mdxType:"CodeBlock"},"\nCode goes here...\n".trim()),(0,l.kt)("h2",null,(0,l.kt)(s.Z,{label:"Other Possible Questions",name:!0,mdxType:"AnchorLink"})),(0,l.kt)("p",null,"We can use it for this problems."),(0,l.kt)("h3",null,(0,l.kt)(s.Z,{label:"$Question-1$",name:!0,mdxType:"AnchorLink"})),(0,l.kt)("p",null,"Below is the Question and its solution."),(0,l.kt)(o.Z,{mdxType:"CodeBlock"},"\nCode goes here...\n".trim()))}h.isMDXComponent=!0},2403:function(t,e,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/blogs/data-structures/stack",function(){return n(2587)}])}},function(t){t.O(0,[329,358,638,774,888,179],(function(){return e=2403,t(t.s=e);var e}));var e=t.O();_N_E=e}]); \ No newline at end of file diff --git a/docs/_next/static/css/1d6713d868a30bd53c27.css b/docs/_next/static/css/ed53f6e7f7199c897a54.css similarity index 76% rename from docs/_next/static/css/1d6713d868a30bd53c27.css rename to docs/_next/static/css/ed53f6e7f7199c897a54.css index 7a673ed..d663a0a 100644 --- a/docs/_next/static/css/1d6713d868a30bd53c27.css +++ b/docs/_next/static/css/ed53f6e7f7199c897a54.css @@ -1 +1 @@ -@import url(https://fonts.googleapis.com/css?family=Open+Sans&display=swap);*{scroll-behavior:smooth}body{font-family:Open Sans,sans-serif}.page{text-align:center}.header-logo{width:250px}.header-logo,.link{cursor:pointer}.photo{border-radius:50%}.postItemList{margin:0 35px}table thead tr th{border-bottom:1px solid grey}table tbody tr td,table thead tr th{padding:5px 10px} \ No newline at end of file +@import url(https://fonts.googleapis.com/css?family=Open+Sans&display=swap);*{scroll-behavior:smooth}body{font-family:Open Sans,sans-serif}.page{text-align:center}.header-logo{width:250px}.header-logo,.link{cursor:pointer}.photo{border-radius:50%}.postItemList{margin:0 35px}table thead tr th{border-bottom:1px solid grey}table tbody tr td,table thead tr th{padding:5px 10px}.token-line:not(:last-child){min-height:1rem} \ No newline at end of file diff --git a/docs/about.html b/docs/about.html index 123a62e..279f002 100644 --- a/docs/about.html +++ b/docs/about.html @@ -1 +1 @@ -About Webslate

👋 Hi, I'm Venkat.R

Venkat.R

Happy to see you visting WebSlate.IO. I'm a JavaScript and web developer living in sunny Singapore creator of WebSlate.IO.

With a passion for teaching, I started making lot of training materials for free. during pandemic 2020, i started helping people who lose jobs through offline now its online called  WebSlate.IO.

I'm just getting started.

\ No newline at end of file +About Webslate

👋 Hi, I'm Venkat.R

Venkat.R

Happy to see you visting WebSlate.IO. I'm a JavaScript and web developer living in sunny Singapore creator of WebSlate.IO.

With a passion for teaching, I started making lot of training materials for free. during pandemic 2020, i started helping people who lose jobs through offline now its online called  WebSlate.IO.

I'm just getting started.

\ No newline at end of file diff --git a/docs/blogs/algorithms.html b/docs/blogs/algorithms.html index 3520058..f4cff1c 100644 --- a/docs/blogs/algorithms.html +++ b/docs/blogs/algorithms.html @@ -1 +1 @@ -Webslate.io - Algorithms

Big-O Notations

Big O notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity. Big O is a member of a family of notations invented by Paul Bachmann.

Aug 8, 202110 mins read
Read more →
\ No newline at end of file +Webslate.io - Algorithms

Big-O Notations

Big O notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity. Big O is a member of a family of notations invented by Paul Bachmann.

Aug 8, 202110 mins read
Read more →
\ No newline at end of file diff --git a/docs/blogs/algorithms/big-o-notations.html b/docs/blogs/algorithms/big-o-notations.html index 9aab78b..7235f03 100644 --- a/docs/blogs/algorithms/big-o-notations.html +++ b/docs/blogs/algorithms/big-o-notations.html @@ -1 +1 @@ -Big-O Notations

Big-O Notations

Aug 8, 202110 mins read

Table of Contents

Big O notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity.

History

  1. Big O is a member of a family of notations invented by Paul Bachmann son of Johann Friedrich Bachmann (1799-1876) and a Lutheran minister (teachings of Jesus Christ and was founded by Martin Luther),
  2. It represents the algorithm’s scalability and performance.

Why Big O Notations? why not with Time?

  1. Not every computer hardware is same. Due to this, efficient code takes long time to execute in old machine or in-efficient code execute quickly in high end machine. but that doesn't meant your code is efficient or in-efficient by evaluating through running time. so we need common notation for better evaluation.

Points To Remember

  1. There are Best, Average and Worst Cases.
  2. Always solve your problem with worst case scenario which is having complex input.
  3. With Big O Notation, we call the size of the input as n.

Order of Growth

ConstantLogarithmicLinearN Log NQuadraticCubicExponential
NO(1)O(log n)O(n)O(n log n)O(n2)O(n3)O(2n)
11111112
21122484
41248166416
81382464512256
161416642564,09665536
3215321601,02432,7684,294,967,296
6416643844,069262,1441.84 X 1019
10241101,02410,2401,048,5761,073,741,824still curious?

Time Complexity

  • Time Complexity is computational complexity that describes the amount of time required to perform the computation.
  • Its helps to estimate the running time of a program.
  • Performing an accurate calculation on program's operation time is labour-intensive process because its depends on the hardware spec like compiler, processor speed.
  • Its important note about Dominant operations are always considered those operation performed largest number of times depends on specific input data.

1. Constant Time O(1)

This takes constant / same time regardless of the number of inputs. always execute in same amount of time, doesn't matter about input size.

Example 1.1: function return whether number is odd or even.

1function isEvenOrOdd(n) {
2 return n % 2 ? 'Odd' : 'Even';
3}

Example 1.2: Look-up table - function return exist key's value.

1const greetTable = { en: 'Hi', fr: '', ta: 'வணக்கம்' }
2function greet(locale = 'en') {
3 return greetTable[locale];
4}

Example 1.2: Find Square of number.

1function square(no) {
2 return no * no
3}

2. Logarithmic Time O(log n)

  1. Most efficient sorts are an example of this, such as merge sort. ​It is O(log n) and search such as Binary Search.
  2. When a complex problem is solved by transforming it into a smaller pieces by some constant fraction is Logarithmic.
  3. This take space proportional to the log of the input size.

Example 2.1: function return logarithmic. value of n is halved on each iteration of the loop.

1function logarithmic(n) {
2 let result = 0
3 while(n>1) {
4 n = n / 2;
5 result = result + 1
6 }
7 return result
8}

3. Linear Time O(n)

Simple multiply table if i pass multiply(2)

1function multiply(no) {
2 for(let i=0;i<=no;i++) {
3 console.log(i, ': ', i*no)
4 }
5}

Space Complexity

  • Space complexity is the amount of memory required to perform the computation by Algorithm
  • Algorithm / Program consider Variables, Program Instruction and Execution, contents of the stack if its recursion.
  • Speed will rely on the computing power of the machine on which it’s executed.
  • Memory limits are crucial and this will share info on expected space complexity.
  • When there is constant numbers of variables, which means you have constant space complexity.

In algorithmics, space and time are like two separate poles. Increasing speed will most often lead to increased memory consumption and vice-versa. for example: merge sort, which is extremely fast but requires a lot of memory and bubble sort, a slow algorithm but one that occupies minimal space.

\ No newline at end of file +Big-O Notations

Big-O Notations

Aug 8, 202110 mins read

Table of Contents

Big O notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity.

History

  1. Big O is a member of a family of notations invented by Paul Bachmann son of Johann Friedrich Bachmann (1799-1876) and a Lutheran minister (teachings of Jesus Christ and was founded by Martin Luther),
  2. It represents the algorithm’s scalability and performance.

Why Big O Notations? why not with Time?

  1. Not every computer hardware is same. Due to this, efficient code takes long time to execute in old machine or in-efficient code execute quickly in high end machine. but that doesn't meant your code is efficient or in-efficient by evaluating through running time. so we need common notation for better evaluation.

Points To Remember

  1. There are Best, Average and Worst Cases.
  2. Always solve your problem with worst case scenario which is having complex input.
  3. With Big O Notation, we call the size of the input as n.

Order of Growth

ConstantLogarithmicLinearN Log NQuadraticCubicExponential
NO(1)O(log n)O(n)O(n log n)O(n2)O(n3)O(2n)
11111112
21122484
41248166416
81382464512256
161416642564,09665536
3215321601,02432,7684,294,967,296
6416643844,069262,1441.84 X 1019
10241101,02410,2401,048,5761,073,741,824still curious?

Time Complexity

  • Time Complexity is computational complexity that describes the amount of time required to perform the computation.
  • Its helps to estimate the running time of a program.
  • Performing an accurate calculation on program's operation time is labour-intensive process because its depends on the hardware spec like compiler, processor speed.
  • Its important note about Dominant operations are always considered those operation performed largest number of times depends on specific input data.

1. Constant Time O(1)

This takes constant / same time regardless of the number of inputs. always execute in same amount of time, doesn't matter about input size.

Example 1.1: function return whether number is odd or even.

1function isEvenOrOdd(n) {
2 return n % 2 ? 'Odd' : 'Even';
3}

Example 1.2: Look-up table - function return exist key's value.

1const greetTable = { en: 'Hi', fr: '', ta: 'வணக்கம்' }
2function greet(locale = 'en') {
3 return greetTable[locale];
4}

Example 1.2: Find Square of number.

1function square(no) {
2 return no * no
3}

2. Logarithmic Time O(log n)

  1. Most efficient sorts are an example of this, such as merge sort. ​It is O(log n) and search such as Binary Search.
  2. When a complex problem is solved by transforming it into a smaller pieces by some constant fraction is Logarithmic.
  3. This take space proportional to the log of the input size.

Example 2.1: function return logarithmic. value of n is halved on each iteration of the loop.

1function logarithmic(n) {
2 let result = 0
3 while(n>1) {
4 n = n / 2;
5 result = result + 1
6 }
7 return result
8}

3. Linear Time O(n)

Simple multiply table if i pass multiply(2)

1function multiply(no) {
2 for(let i=0;i<=no;i++) {
3 console.log(i, ': ', i*no)
4 }
5}

Space Complexity

  • Space complexity is the amount of memory required to perform the computation by Algorithm
  • Algorithm / Program consider Variables, Program Instruction and Execution, contents of the stack if its recursion.
  • Speed will rely on the computing power of the machine on which it’s executed.
  • Memory limits are crucial and this will share info on expected space complexity.
  • When there is constant numbers of variables, which means you have constant space complexity.

In algorithmics, space and time are like two separate poles. Increasing speed will most often lead to increased memory consumption and vice-versa. for example: merge sort, which is extremely fast but requires a lot of memory and bubble sort, a slow algorithm but one that occupies minimal space.

\ No newline at end of file diff --git a/docs/blogs/data-structures.html b/docs/blogs/data-structures.html index a73d756..a0e5dc3 100644 --- a/docs/blogs/data-structures.html +++ b/docs/blogs/data-structures.html @@ -1 +1 @@ -Webslate.io - Data Structures

Stack

Stack is a linear data structure to store a one-dimensional list and store items in LIFO (Last-in, First-Out) or (FILO) First-In, Last-Out

Apr 16, 202010 mins read
Read more →

Tree

Tree is one of the useful data structures

Mar 16, 202010 mins read
Read more →
\ No newline at end of file +Webslate.io - Data Structures

Stack

Stack is a linear data structure to store a one-dimensional list and store items in LIFO (Last-in, First-Out) or (FILO) First-In, Last-Out

Apr 16, 202010 mins read
Read more →

Tree

Tree is one of the useful data structures

Mar 16, 202010 mins read
Read more →
\ No newline at end of file diff --git a/docs/blogs/data-structures/stack.html b/docs/blogs/data-structures/stack.html index 76139f0..536665a 100644 --- a/docs/blogs/data-structures/stack.html +++ b/docs/blogs/data-structures/stack.html @@ -1 +1 @@ -Stack

Stack

Apr 16, 202010 mins read

Table of Contents

What is Stack

  1. Stack is a linear data structure to store a one-dimensional list.
  2. Store items in Last-in, First-Out or First-In, Last-Out(FILO).
1int[] findSignatureCounts(int[] arr)

Constraints

  1. Constraints one
  2. Constraints two

Methods

Below is the complexity table for Stack.


MethodUse
1isEmpty()Return true when Stack is empty
2push()To add item to last
3pop()To remove item which is last
4peek()Return the last item
4size()Return the Stack size

Implementation

Below is the simple example in JavaScript.

1function Stack() {
2 let count = 0;
3 const storage = {};
4 const push = (value) => {
5 storage[count] = value;
6 count++;
7 }
8 const pop = () => {
9 if(count === 0) {
10 return undefined;
11 }
12 count--;
13 const lastValue = storage[count];
14 delete storage[count]
15 return lastValue;
16 }
17 const size = () => {
18 return count;
19 }
20 const peek = () => {
21 return storage[count-1]
22 }
23 return {
24 push,
25 pop,
26 size,
27 peek
28 }
29}

Complexity Table

Below is the complexity table for Stack.


OperationBestAverageWorst
1AccessO(n)O(n)
2SearchO(n)O(n)
3InsertionO(n)O(n)
4DeletionO(n)O(n)
5Space ComplexityO(n)

When do we use Stack

We can use it for this problems.

Real Time Problems

We can use it for this problems.

$Problem-1$

Below is the problem and its solution.

1Code goes here...

Other Possible Questions

We can use it for this problems.

$Question-1$

Below is the Question and its solution.

1Code goes here...
\ No newline at end of file +Stack

Stack

Apr 16, 202010 mins read

Table of Contents

What is Stack

  1. Stack is a linear data structure to store a one-dimensional list.
  2. Store items in Last-in, First-Out or First-In, Last-Out(FILO).
1int[] findSignatureCounts(int[] arr)

Constraints

  1. Constraints one
  2. Constraints two

Methods

Below is the complexity table for Stack.


MethodUse
1isEmpty()Return true when Stack is empty
2push()To add item to last
3pop()To remove item which is last
4peek()Return the last item
4size()Return the Stack size

Implementation

Below is the simple example in JavaScript.

1function Stack() {
2 let count = 0;
3 const storage = {};
4 const push = (value) => {
5 storage[count] = value;
6 count++;
7 }
8 const pop = () => {
9 if(count === 0) {
10 return undefined;
11 }
12 count--;
13 const lastValue = storage[count];
14 delete storage[count]
15 return lastValue;
16 }
17 const size = () => {
18 return count;
19 }
20 const peek = () => {
21 return storage[count-1]
22 }
23 return {
24 push,
25 pop,
26 size,
27 peek
28 }
29}

Complexity Table

Below is the complexity table for Stack.


OperationBestAverageWorst
1AccessO(n)O(n)
2SearchO(n)O(n)
3InsertionO(n)O(n)
4DeletionO(n)O(n)
5Space ComplexityO(n)

When do we use Stack

We can use it for this problems.

Real Time Problems

We can use it for this problems.

$Problem-1$

Below is the problem and its solution.

1Code goes here...

Other Possible Questions

We can use it for this problems.

$Question-1$

Below is the Question and its solution.

1Code goes here...
\ No newline at end of file diff --git a/docs/blogs/data-structures/tree.html b/docs/blogs/data-structures/tree.html index 885983a..6cf0883 100644 --- a/docs/blogs/data-structures/tree.html +++ b/docs/blogs/data-structures/tree.html @@ -1 +1 @@ -Tree

Tree

Mar 16, 202010 mins read
1function findSignatureCounts(arr) {
2 const ans = Array(arr.length).fill(1);
3 // Iterate Array.
4 for (let i = 0; i < arr.length; i++) {
5 let k = i;
6 while (arr[k] !== i + 1) {
7 ans[i]++;
8 k = arr[k] - 1;
9 }
10 }
11 return ans;
12}

On High level note, It worth to read in detail for a better understanding.

Table of Contents

Problem Statement

There are n students, numbered from 1 to n, each with their own yearbook. They would like to pass their yearbooks around and get them signed by other students.

You're given a list of n integers arr[1..n], which is guaranteed to be a permutation of 1..n (in other words, it includes the integers from 1 to n exactly once each, in some order). The meaning of this list is described below.

Initially, each student is holding their own yearbook. The students will then repeat the following two steps each minute: Each student i will first sign the yearbook that they're currently holding (which may either belong to themselves or to another student), and then they'll pass it to student arr[i-1]. It's possible that arr[i-1] = i for any given i, in which case student i will pass their yearbook back to themselves. Once a student has received their own yearbook back, they will hold on to it and no longer participate in the passing process.

It's guaranteed that, for any possible valid input, each student will eventually receive their own yearbook back and will never end up holding more than one yearbook at a time.

You must compute a list of n integers output, whose element at i-1 is equal to the number of signatures that will be present in student i's yearbook once they receive it back.

1int[] findSignatureCounts(int[] arr)

Constraints

  1. n is in the range [1, 100,000].
  2. Each value arr[i] is in the range [1, n], and all values in arr[i] are distinct.

Expected

  1. Return a list of n integers output, as described above.

Test Cases

  1. n = 2, arr = [2, 1] and output = [2, 2]
  2. n = 2, arr = [1, 2] and output = [1, 1]

Foot Note

  • Test Case 1 Explaination:

    • Pass 1:
      • Student 1 signs their own yearbook. Then they pass the book to the student at arr[0], which is Student 2.
      • Student 2 signs their own yearbook. Then they pass the book to the student at arr[1], which is Student 1.
    • Pass 2:
      • Student 1 signs Student 2's yearbook. Then they pass it to the student at arr[0], which is Student 2.
      • Student 2 signs Student 1's yearbook. Then they pass it to the student at arr[1], which is Student 1.
    • Pass 3:
      • Both students now hold their own yearbook, so the process is complete.
    • Result: Each student received 2 signatures.
  • Test Case 2 Explaination:

    • Pass 1:
      • Student 1 signs their own yearbook. Then they pass the book to the student at arr[0], which is themself, Student 1.
      • Student 2 signs their own yearbook. Then they pass the book to the student at arr[1], which is themself, Student 2.
    • Pass 2:
      • Both students now hold their own yearbook, so the process is complete.
    • Result: Each student received 1 signature.

Solution Intro

Lets see the list of approaches and their complexities.


ApproachTime ComplexitySpace Complexity
1Brute ForceO(n+m)O(m+n)
2$Approach 1$O(n)O(n)
3$Approach 2$O(n)O(n)
4Time OptimizedO(n)O(n)
5Memory OptimizedO(n)O(n)

Solutions

With no further due, lets take a example of code solutions.

Brute Force

Description

1Code goes here...

$Approach-1$

Description

1Code goes here...

$Approach-2$

Description

1Code goes here...

$Time-Optimized$

Description

1Code goes here...
### $Space-Optimized$Description
1Code goes here...
\ No newline at end of file +Tree

Tree

Mar 16, 202010 mins read
1function findSignatureCounts(arr) {
2 const ans = Array(arr.length).fill(1);
3 // Iterate Array.
4 for (let i = 0; i < arr.length; i++) {
5 let k = i;
6 while (arr[k] !== i + 1) {
7 ans[i]++;
8 k = arr[k] - 1;
9 }
10 }
11 return ans;
12}

On High level note, It worth to read in detail for a better understanding.

Table of Contents

Problem Statement

There are n students, numbered from 1 to n, each with their own yearbook. They would like to pass their yearbooks around and get them signed by other students.

You're given a list of n integers arr[1..n], which is guaranteed to be a permutation of 1..n (in other words, it includes the integers from 1 to n exactly once each, in some order). The meaning of this list is described below.

Initially, each student is holding their own yearbook. The students will then repeat the following two steps each minute: Each student i will first sign the yearbook that they're currently holding (which may either belong to themselves or to another student), and then they'll pass it to student arr[i-1]. It's possible that arr[i-1] = i for any given i, in which case student i will pass their yearbook back to themselves. Once a student has received their own yearbook back, they will hold on to it and no longer participate in the passing process.

It's guaranteed that, for any possible valid input, each student will eventually receive their own yearbook back and will never end up holding more than one yearbook at a time.

You must compute a list of n integers output, whose element at i-1 is equal to the number of signatures that will be present in student i's yearbook once they receive it back.

1int[] findSignatureCounts(int[] arr)

Constraints

  1. n is in the range [1, 100,000].
  2. Each value arr[i] is in the range [1, n], and all values in arr[i] are distinct.

Expected

  1. Return a list of n integers output, as described above.

Test Cases

  1. n = 2, arr = [2, 1] and output = [2, 2]
  2. n = 2, arr = [1, 2] and output = [1, 1]

Foot Note

  • Test Case 1 Explaination:

    • Pass 1:
      • Student 1 signs their own yearbook. Then they pass the book to the student at arr[0], which is Student 2.
      • Student 2 signs their own yearbook. Then they pass the book to the student at arr[1], which is Student 1.
    • Pass 2:
      • Student 1 signs Student 2's yearbook. Then they pass it to the student at arr[0], which is Student 2.
      • Student 2 signs Student 1's yearbook. Then they pass it to the student at arr[1], which is Student 1.
    • Pass 3:
      • Both students now hold their own yearbook, so the process is complete.
    • Result: Each student received 2 signatures.
  • Test Case 2 Explaination:

    • Pass 1:
      • Student 1 signs their own yearbook. Then they pass the book to the student at arr[0], which is themself, Student 1.
      • Student 2 signs their own yearbook. Then they pass the book to the student at arr[1], which is themself, Student 2.
    • Pass 2:
      • Both students now hold their own yearbook, so the process is complete.
    • Result: Each student received 1 signature.

Solution Intro

Lets see the list of approaches and their complexities.


ApproachTime ComplexitySpace Complexity
1Brute ForceO(n+m)O(m+n)
2$Approach 1$O(n)O(n)
3$Approach 2$O(n)O(n)
4Time OptimizedO(n)O(n)
5Memory OptimizedO(n)O(n)

Solutions

With no further due, lets take a example of code solutions.

Brute Force

Description

1Code goes here...

$Approach-1$

Description

1Code goes here...

$Approach-2$

Description

1Code goes here...

$Time-Optimized$

Description

1Code goes here...
### $Space-Optimized$Description
1Code goes here...
\ No newline at end of file diff --git a/docs/blogs/html.html b/docs/blogs/html.html index 91194a2..a40e71b 100644 --- a/docs/blogs/html.html +++ b/docs/blogs/html.html @@ -1 +1 @@ -Webslate.io - HTML5 Articles

Storage API

learn more about Storage API (Local and Session Storage).

Aug 8, 20162 mins read
Read more →
\ No newline at end of file +Webslate.io - HTML5 Articles

Storage API

learn more about Storage API (Local and Session Storage).

Aug 8, 20162 mins read
Read more →
\ No newline at end of file diff --git a/docs/blogs/html/storage-api.html b/docs/blogs/html/storage-api.html index 839e229..84fe83b 100644 --- a/docs/blogs/html/storage-api.html +++ b/docs/blogs/html/storage-api.html @@ -1 +1 @@ -Storage API

Storage API

Aug 8, 20162 mins read

One of the good Features in ES6 is Promises Object and their useful methods and they are called software abstraction helps to works smoothly with asynchronous operations. Promise API followed Promises/A+ Specification prior to this, there was Promise/A.

What is Promises/A and Promises/A+ ?

  1. Both are specification for open standard but Javascript currently uses Promise/A+.
  2. The main three reason for using Promise/A+ is Three different states, Value for Fulfilment and for Rejection and thenable object. for more detail see Differences from Promises/A
  3. These Promise/A+ organisation occasionally revise and address the corner cases in to new Specification.

Difference between Promise/A and /A+?

  1. Rejection / Fulfilment method returns thenable object.
  2. Rejection triggers catch method, if errors thrown.

In short, running continuation-passing style. Let me shoot few bullets with simple diagram on Promises below.

\ No newline at end of file +Storage API

Storage API

Aug 8, 20162 mins read

One of the good Features in ES6 is Promises Object and their useful methods and they are called software abstraction helps to works smoothly with asynchronous operations. Promise API followed Promises/A+ Specification prior to this, there was Promise/A.

What is Promises/A and Promises/A+ ?

  1. Both are specification for open standard but Javascript currently uses Promise/A+.
  2. The main three reason for using Promise/A+ is Three different states, Value for Fulfilment and for Rejection and thenable object. for more detail see Differences from Promises/A
  3. These Promise/A+ organisation occasionally revise and address the corner cases in to new Specification.

Difference between Promise/A and /A+?

  1. Rejection / Fulfilment method returns thenable object.
  2. Rejection triggers catch method, if errors thrown.

In short, running continuation-passing style. Let me shoot few bullets with simple diagram on Promises below.

\ No newline at end of file diff --git a/docs/blogs/js.html b/docs/blogs/js.html index ff96e04..97b2f9f 100644 --- a/docs/blogs/js.html +++ b/docs/blogs/js.html @@ -1 +1 @@ -Webslate.io - Javascript Articles

JS Promise (Part 2 - Q.js, When.js and RSVP.js)

I would like to continue with an examination of JavaScript Promise API. Let’s have a look at Promise evolution by various libraries. below three libraries which we are going to explore on this article.

Dec 5, 20165 mins read
Read more →

JS Promises Basics (Part 1)

One of the good Features in ES6 is Promises Object and their useful methods and they are called software abstraction helps to works smoothly with asynchronous operations. Promise API followed Promises/A+ Specification prior to this, there was Promise/A.

Oct 21, 20162 mins read
Read more →
\ No newline at end of file +Webslate.io - Javascript Articles

JS Promise (Part 2 - Q.js, When.js and RSVP.js)

I would like to continue with an examination of JavaScript Promise API. Let’s have a look at Promise evolution by various libraries. below three libraries which we are going to explore on this article.

Dec 5, 20165 mins read
Read more →

JS Promises Basics (Part 1)

One of the good Features in ES6 is Promises Object and their useful methods and they are called software abstraction helps to works smoothly with asynchronous operations. Promise API followed Promises/A+ Specification prior to this, there was Promise/A.

Oct 21, 20162 mins read
Read more →
\ No newline at end of file diff --git a/docs/blogs/js/promises-part-2.html b/docs/blogs/js/promises-part-2.html index 9330802..fe89292 100644 --- a/docs/blogs/js/promises-part-2.html +++ b/docs/blogs/js/promises-part-2.html @@ -1 +1 @@ -JS Promise (Part 2 - Q.js, When.js and RSVP.js)

JS Promise (Part 2 - Q.js, When.js and RSVP.js)

Dec 5, 20165 mins read

I would like to continue with an examination of JavaScript Promise API. Let’s have a look at Promise evolution by various libraries. below three libraries which we are going to explore on this article.

  1. Q.js Library
  2. When.js Library
  3. RSVP.js Library

Using q.js

The q.js is best one for promise implementation by Kris Kowal. It is more evident of promise evolution.

Lets have a look, What makes it special.

  • It provides two ways to define the promise. one is very famous by Q.defer() and another one is Q.Promise().
  • The Q.defer() method is custom and flexible way to define promise like defining anywhere in the code likevar deferred = Q.defer(); and any time that can be resolved, rejected and notified (deferred.resolve, deferred.reject, deferred.notify).
\ No newline at end of file +JS Promise (Part 2 - Q.js, When.js and RSVP.js)

JS Promise (Part 2 - Q.js, When.js and RSVP.js)

Dec 5, 20165 mins read

I would like to continue with an examination of JavaScript Promise API. Let’s have a look at Promise evolution by various libraries. below three libraries which we are going to explore on this article.

  1. Q.js Library
  2. When.js Library
  3. RSVP.js Library

Using q.js

The q.js is best one for promise implementation by Kris Kowal. It is more evident of promise evolution.

Lets have a look, What makes it special.

  • It provides two ways to define the promise. one is very famous by Q.defer() and another one is Q.Promise().
  • The Q.defer() method is custom and flexible way to define promise like defining anywhere in the code likevar deferred = Q.defer(); and any time that can be resolved, rejected and notified (deferred.resolve, deferred.reject, deferred.notify).
\ No newline at end of file diff --git a/docs/blogs/js/promises.html b/docs/blogs/js/promises.html index dd367f3..8ec9d72 100644 --- a/docs/blogs/js/promises.html +++ b/docs/blogs/js/promises.html @@ -1 +1 @@ -JS Promises Basics (Part 1)

JS Promises Basics (Part 1)

Oct 21, 20162 mins read

One of the good Features in ES6 is Promises Object and their useful methods and they are called software abstraction helps to works smoothly with asynchronous operations. Promise API followed Promises/A+ Specification prior to this, there was Promise/A.

What is Promises/A and Promises/A+ ?

  1. Both are specification for open standard but Javascript currently uses Promise/A+.
  2. The main three reason for using Promise/A+ is Three different states, Value for Fulfilment and for Rejection and thenable object. for more detail see Differences from Promises/A
  3. These Promise/A+ organisation occasionally revise and address the corner cases in to new Specification.

Difference between Promise/A and /A+?

  1. Rejection / Fulfilment method returns thenable object.
  2. Rejection triggers catch method, if errors thrown.

In short, running continuation-passing style. Let me shoot few bullets with simple diagram on Promises below.

\ No newline at end of file +JS Promises Basics (Part 1)

JS Promises Basics (Part 1)

Oct 21, 20162 mins read

One of the good Features in ES6 is Promises Object and their useful methods and they are called software abstraction helps to works smoothly with asynchronous operations. Promise API followed Promises/A+ Specification prior to this, there was Promise/A.

What is Promises/A and Promises/A+ ?

  1. Both are specification for open standard but Javascript currently uses Promise/A+.
  2. The main three reason for using Promise/A+ is Three different states, Value for Fulfilment and for Rejection and thenable object. for more detail see Differences from Promises/A
  3. These Promise/A+ organisation occasionally revise and address the corner cases in to new Specification.

Difference between Promise/A and /A+?

  1. Rejection / Fulfilment method returns thenable object.
  2. Rejection triggers catch method, if errors thrown.

In short, running continuation-passing style. Let me shoot few bullets with simple diagram on Promises below.

\ No newline at end of file diff --git a/docs/blogs/mobile.html b/docs/blogs/mobile.html index 2a9cde3..9fd6adb 100644 --- a/docs/blogs/mobile.html +++ b/docs/blogs/mobile.html @@ -1 +1 @@ -Webslate.io - Mobile Articles

Deep Linking

Understand deep links in 5 minutes

Jul 21, 20202 mins read
Read more →
\ No newline at end of file +Webslate.io - Mobile Articles

Deep Linking

Understand deep links in 5 minutes

Jul 21, 20202 mins read
Read more →
\ No newline at end of file diff --git a/docs/blogs/mobile/deep-link.html b/docs/blogs/mobile/deep-link.html index 32b3429..4bb782c 100644 --- a/docs/blogs/mobile/deep-link.html +++ b/docs/blogs/mobile/deep-link.html @@ -1 +1 @@ -Deep Linking

Deep Linking

Jul 21, 20202 mins read

Coming soon

\ No newline at end of file +Deep Linking

Deep Linking

Jul 21, 20202 mins read

Coming soon

\ No newline at end of file diff --git a/docs/blogs/performance.html b/docs/blogs/performance.html index 70c11b7..cf54ba1 100644 --- a/docs/blogs/performance.html +++ b/docs/blogs/performance.html @@ -1 +1 @@ -Webslate.io - Performance Articles

Optimize Web Bundles

Tricks to optimize Web Bundle File Size

Jul 21, 20202 mins read
Read more →
\ No newline at end of file +Webslate.io - Performance Articles

Optimize Web Bundles

Tricks to optimize Web Bundle File Size

Jul 21, 20202 mins read
Read more →
\ No newline at end of file diff --git a/docs/blogs/performance/optimize-web-bundles.html b/docs/blogs/performance/optimize-web-bundles.html index e5dc28d..70343fe 100644 --- a/docs/blogs/performance/optimize-web-bundles.html +++ b/docs/blogs/performance/optimize-web-bundles.html @@ -1 +1 @@ -Optimize Web Bundles

Optimize Web Bundles

Jul 21, 20202 mins read

Coming soon

\ No newline at end of file +Optimize Web Bundles

Optimize Web Bundles

Jul 21, 20202 mins read

Coming soon

\ No newline at end of file diff --git a/docs/blogs/problems.html b/docs/blogs/problems.html index dd2131d..ef5860e 100644 --- a/docs/blogs/problems.html +++ b/docs/blogs/problems.html @@ -1 +1 @@ -Webslate.io - Problems

Passing Yearbooks

There are n students, numbered from 1 to n, each with their own yearbook. They would like to pass their yearbooks around and get them signed by other students.

Mar 16, 202010 mins read
Read more →

Reverse to Make Equal

Given two arrays A and B of length N, determine if there is a way to make A equal to B by reversing any subarrays from array B any number of times.

Feb 7, 202010 mins read
Read more →

Fibonacci Series

Fibonacci numbers, commonly denoted Fn sequence

Aug 7, 202110 mins read
Read more →

Missing element in Permutation.

Find the missing element in a given permutation.

Jul 21, 20202 mins read
Read more →

Palindrome Solutions

Palindrome is in reverse also same

Jul 21, 20202 mins read
Read more →

Frog Jump Solution

Count minimal number of jumps from position X to Y.

Jul 21, 20202 mins read
Read more →

Tape Equilibrium

Palindrome is in reverse also same

Jul 21, 20202 mins read
Read more →
\ No newline at end of file +Webslate.io - Problems

Passing Yearbooks

There are n students, numbered from 1 to n, each with their own yearbook. They would like to pass their yearbooks around and get them signed by other students.

Mar 16, 202010 mins read
Read more →

Reverse to Make Equal

Given two arrays A and B of length N, determine if there is a way to make A equal to B by reversing any subarrays from array B any number of times.

Feb 7, 202010 mins read
Read more →

Fibonacci Series

Fibonacci numbers, commonly denoted Fn sequence

Aug 7, 202110 mins read
Read more →

Missing element in Permutation.

Find the missing element in a given permutation.

Jul 21, 20202 mins read
Read more →

Palindrome Solutions

Palindrome is in reverse also same

Jul 21, 20202 mins read
Read more →

Frog Jump Solution

Count minimal number of jumps from position X to Y.

Jul 21, 20202 mins read
Read more →

Tape Equilibrium

Palindrome is in reverse also same

Jul 21, 20202 mins read
Read more →
\ No newline at end of file diff --git a/docs/blogs/problems/array-intersection.html b/docs/blogs/problems/array-intersection.html index 213eef6..34c9e52 100644 --- a/docs/blogs/problems/array-intersection.html +++ b/docs/blogs/problems/array-intersection.html @@ -1 +1 @@ -$Title$

$Title$

Feb 7, 202010 mins read

Straight to the Point !

Are you landed to this page and rushing for the immediate solution in javascript. here you go !!

10, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89

On High level note, It worth to read in detail for a better understanding.

Table of Contents

$desc$

10, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89

Problem Statement

  1. Goes here

Constraints

  1. Goes here

Expected

  1. Goes here

Foot Note

  1. Goes here

Solution Intro

Lets see the list of approaches and their complexities.


Rabbits Population per year.

ApproachTime ComplexitySpace Complexity
1Brute ForceO(n+mO(m+n)
2$Approach 1$O(n)O(n)
3$Approach 2$O(n)O(n)
4Time OptimizedO(n)O(n)
5Memory OptimizedO(n)O(n)

Solutions

With no further due, lets take a example of code solutions.

Brute Force

Description

1Code goes here...

$Approach-1$

Description

1Code goes here...

$Approach-2$

Description

1Code goes here...

$Time-Optimized$

Description

1Code goes here...

$Space-Optimized$

Description

1Code goes here...
\ No newline at end of file +$Title$

$Title$

Feb 7, 202010 mins read

Straight to the Point !

Are you landed to this page and rushing for the immediate solution in javascript. here you go !!

10, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89

On High level note, It worth to read in detail for a better understanding.

Table of Contents

$desc$

10, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89

Problem Statement

  1. Goes here

Constraints

  1. Goes here

Expected

  1. Goes here

Foot Note

  1. Goes here

Solution Intro

Lets see the list of approaches and their complexities.


Rabbits Population per year.

ApproachTime ComplexitySpace Complexity
1Brute ForceO(n+mO(m+n)
2$Approach 1$O(n)O(n)
3$Approach 2$O(n)O(n)
4Time OptimizedO(n)O(n)
5Memory OptimizedO(n)O(n)

Solutions

With no further due, lets take a example of code solutions.

Brute Force

Description

1Code goes here...

$Approach-1$

Description

1Code goes here...

$Approach-2$

Description

1Code goes here...

$Time-Optimized$

Description

1Code goes here...

$Space-Optimized$

Description

1Code goes here...
\ No newline at end of file diff --git a/docs/blogs/problems/facebook-passing-year-books.html b/docs/blogs/problems/facebook-passing-year-books.html index d2b933b..3f19464 100644 --- a/docs/blogs/problems/facebook-passing-year-books.html +++ b/docs/blogs/problems/facebook-passing-year-books.html @@ -1 +1 @@ -Passing Yearbooks

Passing Yearbooks

Mar 16, 202010 mins read

Straight to the Point !

Are you landed to this page and rushing for the immediate solution in javascript. here you go !!

1function findSignatureCounts(arr) {
2 const ans = Array(arr.length).fill(1);
3 // Iterate Array.
4 for (let i = 0; i < arr.length; i++) {
5 let k = i;
6 while (arr[k] !== i + 1) {
7 ans[i]++;
8 k = arr[k] - 1;
9 }
10 }
11 return ans;
12}

On High level note, It worth to read in detail for a better understanding.

Table of Contents

Problem Statement

There are n students, numbered from 1 to n, each with their own yearbook. They would like to pass their yearbooks around and get them signed by other students.

You're given a list of n integers arr[1..n], which is guaranteed to be a permutation of 1..n (in other words, it includes the integers from 1 to n exactly once each, in some order). The meaning of this list is described below.

Initially, each student is holding their own yearbook. The students will then repeat the following two steps each minute: Each student i will first sign the yearbook that they're currently holding (which may either belong to themselves or to another student), and then they'll pass it to student arr[i-1]. It's possible that arr[i-1] = i for any given i, in which case student i will pass their yearbook back to themselves. Once a student has received their own yearbook back, they will hold on to it and no longer participate in the passing process.

It's guaranteed that, for any possible valid input, each student will eventually receive their own yearbook back and will never end up holding more than one yearbook at a time.

You must compute a list of n integers output, whose element at i-1 is equal to the number of signatures that will be present in student i's yearbook once they receive it back.

1int[] findSignatureCounts(int[] arr)

Constraints

  1. n is in the range [1, 100,000].
  2. Each value arr[i] is in the range [1, n], and all values in arr[i] are distinct.

Expected

  1. Return a list of n integers output, as described above.

Test Cases

  1. n = 2, arr = [2, 1] and output = [2, 2]
  2. n = 2, arr = [1, 2] and output = [1, 1]

Foot Note

  • Test Case 1 Explaination:

    • Pass 1:
      • Student 1 signs their own yearbook. Then they pass the book to the student at arr[0], which is Student 2.
      • Student 2 signs their own yearbook. Then they pass the book to the student at arr[1], which is Student 1.
    • Pass 2:
      • Student 1 signs Student 2's yearbook. Then they pass it to the student at arr[0], which is Student 2.
      • Student 2 signs Student 1's yearbook. Then they pass it to the student at arr[1], which is Student 1.
    • Pass 3:
      • Both students now hold their own yearbook, so the process is complete.
    • Result: Each student received 2 signatures.
  • Test Case 2 Explaination:

    • Pass 1:
      • Student 1 signs their own yearbook. Then they pass the book to the student at arr[0], which is themself, Student 1.
      • Student 2 signs their own yearbook. Then they pass the book to the student at arr[1], which is themself, Student 2.
    • Pass 2:
      • Both students now hold their own yearbook, so the process is complete.
    • Result: Each student received 1 signature.

Solution Intro

Lets see the list of approaches and their complexities.


ApproachTime ComplexitySpace Complexity
1Brute ForceO(n+m)O(m+n)
2$Approach 1$O(n)O(n)
3$Approach 2$O(n)O(n)
4Time OptimizedO(n)O(n)
5Memory OptimizedO(n)O(n)

Solutions

With no further due, lets take a example of code solutions.

Brute Force

Description

1Code goes here...

$Approach-1$

Description

1Code goes here...

$Approach-2$

Description

1Code goes here...

$Time-Optimized$

Description

1Code goes here...
### $Space-Optimized$Description
1Code goes here...
\ No newline at end of file +Passing Yearbooks

Passing Yearbooks

Mar 16, 202010 mins read

Straight to the Point !

Are you landed to this page and rushing for the immediate solution in javascript. here you go !!

1function findSignatureCounts(arr) {
2 const ans = Array(arr.length).fill(1);
3 // Iterate Array.
4 for (let i = 0; i < arr.length; i++) {
5 let k = i;
6 while (arr[k] !== i + 1) {
7 ans[i]++;
8 k = arr[k] - 1;
9 }
10 }
11 return ans;
12}

On High level note, It worth to read in detail for a better understanding.

Table of Contents

Problem Statement

There are n students, numbered from 1 to n, each with their own yearbook. They would like to pass their yearbooks around and get them signed by other students.

You're given a list of n integers arr[1..n], which is guaranteed to be a permutation of 1..n (in other words, it includes the integers from 1 to n exactly once each, in some order). The meaning of this list is described below.

Initially, each student is holding their own yearbook. The students will then repeat the following two steps each minute: Each student i will first sign the yearbook that they're currently holding (which may either belong to themselves or to another student), and then they'll pass it to student arr[i-1]. It's possible that arr[i-1] = i for any given i, in which case student i will pass their yearbook back to themselves. Once a student has received their own yearbook back, they will hold on to it and no longer participate in the passing process.

It's guaranteed that, for any possible valid input, each student will eventually receive their own yearbook back and will never end up holding more than one yearbook at a time.

You must compute a list of n integers output, whose element at i-1 is equal to the number of signatures that will be present in student i's yearbook once they receive it back.

1int[] findSignatureCounts(int[] arr)

Constraints

  1. n is in the range [1, 100,000].
  2. Each value arr[i] is in the range [1, n], and all values in arr[i] are distinct.

Expected

  1. Return a list of n integers output, as described above.

Test Cases

  1. n = 2, arr = [2, 1] and output = [2, 2]
  2. n = 2, arr = [1, 2] and output = [1, 1]

Foot Note

  • Test Case 1 Explaination:

    • Pass 1:
      • Student 1 signs their own yearbook. Then they pass the book to the student at arr[0], which is Student 2.
      • Student 2 signs their own yearbook. Then they pass the book to the student at arr[1], which is Student 1.
    • Pass 2:
      • Student 1 signs Student 2's yearbook. Then they pass it to the student at arr[0], which is Student 2.
      • Student 2 signs Student 1's yearbook. Then they pass it to the student at arr[1], which is Student 1.
    • Pass 3:
      • Both students now hold their own yearbook, so the process is complete.
    • Result: Each student received 2 signatures.
  • Test Case 2 Explaination:

    • Pass 1:
      • Student 1 signs their own yearbook. Then they pass the book to the student at arr[0], which is themself, Student 1.
      • Student 2 signs their own yearbook. Then they pass the book to the student at arr[1], which is themself, Student 2.
    • Pass 2:
      • Both students now hold their own yearbook, so the process is complete.
    • Result: Each student received 1 signature.

Solution Intro

Lets see the list of approaches and their complexities.


ApproachTime ComplexitySpace Complexity
1Brute ForceO(n+m)O(m+n)
2$Approach 1$O(n)O(n)
3$Approach 2$O(n)O(n)
4Time OptimizedO(n)O(n)
5Memory OptimizedO(n)O(n)

Solutions

With no further due, lets take a example of code solutions.

Brute Force

Description

1Code goes here...

$Approach-1$

Description

1Code goes here...

$Approach-2$

Description

1Code goes here...

$Time-Optimized$

Description

1Code goes here...
### $Space-Optimized$Description
1Code goes here...
\ No newline at end of file diff --git a/docs/blogs/problems/facebook-reverse-to-make-equal-array.html b/docs/blogs/problems/facebook-reverse-to-make-equal-array.html index f842528..a302963 100644 --- a/docs/blogs/problems/facebook-reverse-to-make-equal-array.html +++ b/docs/blogs/problems/facebook-reverse-to-make-equal-array.html @@ -1,5 +1,5 @@ -Reverse to Make Equal

Reverse to Make Equal

Feb 7, 202010 mins read

Straight to the Point !

Are you landed to this page and rushing for the immediate solution in javascript. here you go !!

1function areTheyEqual(array_a, array_b) {
2const data = {};
3for (let targetArrayIndex = 0; targetArrayIndex < array_a.length; ++targetArrayIndex) {
4 data[array_a[targetArrayIndex]] = data[array_a[targetArrayIndex]] + 1 || 1
5}
6// Iterating Array B.
7for (let arrayIndex = 0; arrayIndex < array_b.length; ++arrayIndex) {
8 const arrayBValueInDataHashMap = data[array_b[arrayIndex]];
9 if (!arrayBValueInDataHashMap) return false;
10 if (!!arrayBValueInDataHashMap) {
11 if (arrayBValueInDataHashMap < 1) {
12 return false;
13 }
14 data[array_b[arrayIndex]] = data[array_b[arrayIndex]] - 1
15 }
16}
17return true
18};

On High level note, It worth to read in detail for a better understanding.
+Reverse to Make Equal

Reverse to Make Equal

Feb 7, 202010 mins read

Straight to the Point !

Are you landed to this page and rushing for the immediate solution in javascript. here you go !!

1function areTheyEqual(array_a, array_b) {
2const data = {};
3for (let targetArrayIndex = 0; targetArrayIndex < array_a.length; ++targetArrayIndex) {
4 data[array_a[targetArrayIndex]] = data[array_a[targetArrayIndex]] + 1 || 1
5}
6// Iterating Array B.
7for (let arrayIndex = 0; arrayIndex < array_b.length; ++arrayIndex) {
8 const arrayBValueInDataHashMap = data[array_b[arrayIndex]];
9 if (!arrayBValueInDataHashMap) return false;
10 if (!!arrayBValueInDataHashMap) {
11 if (arrayBValueInDataHashMap < 1) {
12 return false;
13 }
14 data[array_b[arrayIndex]] = data[array_b[arrayIndex]] - 1
15 }
16}
17return true
18};

On High level note, It worth to read in detail for a better understanding.
This is one of the Facebook interview question and Leet code problem as well - 1460. Make Two Arrays Equal by Reversing Sub-arrays

Table of Contents

Given two arrays A and B of length N, determine if there is a way to make A equal to B by reversing any subarrays from array B any number of times.

1bool areTheyEqual(int[] arr_a, int[] arr_b)

Problem Statement

A = [1, 2, 3, 4] B = [1, 4, 3, 2] output = true

Constraints

All integers in array are in the range [0, 1,000,000,000].
-As per, Leet Code

  1. target.length == arr.length
  2. 1 <= target.length <= 1000
  3. 1 <= target[i] <= 1000
  4. 1 <= arr[i] <= 1000

Expected

Return true if B can be made equal to A, return false otherwise.

Foot Note

  1. Each element of target should have a corresponding element in arr, and if it doesn't have a corresponding element, return false.
  2. To solve it easiely you can sort the two arrays and check if they are equal.

Solution Intro

Lets see the list of approaches and their complexities.


ApproachTime ComplexitySpace Complexity
1Brute Force (Use HashMap with Two for...loop)O(n+mO(m+n)
2Sort and Stringify both ArrayO(2n+2m)O(n+m)
3Use HashMap with Two for...loopO(2n+m)O(n+m)
4Time Optimized (2nd Solution)O(2n+2m)O(n+m)
5Memory Optimized (3rd Solution)O(2n+m)O(n+m)

Solutions

With no further due, lets take a example of code solutions.

Brute Force

Below solution sort both array then iterate the first array to check each index value is same, method returns false if there is no match with same index in both array.

1function(target, arr) {
2 if (target.length === 0 || arr.length === 0) return false;
3 if (target.length !== arr.length) return false;
4 const sortedTarget = target.sort((a,b) => a -b);
5 const sortedArray = arr.sort((a,b) => a -b);
6 // Iterate Target Elements.
7 for(let index = 0;index<sortedTarget.length;index++) {
8 if(sortedTarget[index] !== sortedArray[index]) {
9 return false;
10 }
11 }
12 return true;
13};

Sort and Stringify both Array

Using JS predefined method sort and join, basically this Sort and Stringify both array elements.

1function(target, arr) {
2 return target.sort().join("") === arr.sort().join("");
3};

Use HashMap with Two for...loop

Basically, this stores the elements value in hashmap as property name and value as number of occurence and then iterate the second array to check the hashmap is exist with greater than zero and then decrement the hashmap property value when occurence if exist in second array.

1function(target, arr) {
2const data = {};
3for (let targetArrayIndex = 0; targetArrayIndex < array_a.length; ++targetArrayIndex) {
4 data[array_a[targetArrayIndex]] = data[array_a[targetArrayIndex]] + 1 || 1
5}
6// Iterating Array B.
7for (let arrayIndex = 0; arrayIndex < array_b.length; ++arrayIndex) {
8 const arrayBValueInDataHashMap = data[array_b[arrayIndex]];
9 if (!arrayBValueInDataHashMap) return false;
10 if (!!arrayBValueInDataHashMap) {
11 if (arrayBValueInDataHashMap < 1) {
12 return false;
13 }
14 data[array_b[arrayIndex]] = data[array_b[arrayIndex]] - 1
15 }
16}
17return true
18};

Time Optimized

Time Optimized is Sort and Stringify both Array which is second solution.

Space Optimized

Space Optimized is Brute Force Code solution.

\ No newline at end of file +As per, Leet Code

  1. target.length == arr.length
  2. 1 <= target.length <= 1000
  3. 1 <= target[i] <= 1000
  4. 1 <= arr[i] <= 1000

Expected

Return true if B can be made equal to A, return false otherwise.

Foot Note

  1. Each element of target should have a corresponding element in arr, and if it doesn't have a corresponding element, return false.
  2. To solve it easiely you can sort the two arrays and check if they are equal.

Solution Intro

Lets see the list of approaches and their complexities.


ApproachTime ComplexitySpace Complexity
1Brute Force (Use HashMap with Two for...loop)O(n+mO(m+n)
2Sort and Stringify both ArrayO(2n+2m)O(n+m)
3Use HashMap with Two for...loopO(2n+m)O(n+m)
4Time Optimized (2nd Solution)O(2n+2m)O(n+m)
5Memory Optimized (3rd Solution)O(2n+m)O(n+m)

Solutions

With no further due, lets take a example of code solutions.

Brute Force

Below solution sort both array then iterate the first array to check each index value is same, method returns false if there is no match with same index in both array.

1function(target, arr) {
2 if (target.length === 0 || arr.length === 0) return false;
3 if (target.length !== arr.length) return false;
4 const sortedTarget = target.sort((a,b) => a -b);
5 const sortedArray = arr.sort((a,b) => a -b);
6 // Iterate Target Elements.
7 for(let index = 0;index<sortedTarget.length;index++) {
8 if(sortedTarget[index] !== sortedArray[index]) {
9 return false;
10 }
11 }
12 return true;
13};

Sort and Stringify both Array

Using JS predefined method sort and join, basically this Sort and Stringify both array elements.

1function(target, arr) {
2 return target.sort().join("") === arr.sort().join("");
3};

Use HashMap with Two for...loop

Basically, this stores the elements value in hashmap as property name and value as number of occurence and then iterate the second array to check the hashmap is exist with greater than zero and then decrement the hashmap property value when occurence if exist in second array.

1function(target, arr) {
2const data = {};
3for (let targetArrayIndex = 0; targetArrayIndex < array_a.length; ++targetArrayIndex) {
4 data[array_a[targetArrayIndex]] = data[array_a[targetArrayIndex]] + 1 || 1
5}
6// Iterating Array B.
7for (let arrayIndex = 0; arrayIndex < array_b.length; ++arrayIndex) {
8 const arrayBValueInDataHashMap = data[array_b[arrayIndex]];
9 if (!arrayBValueInDataHashMap) return false;
10 if (!!arrayBValueInDataHashMap) {
11 if (arrayBValueInDataHashMap < 1) {
12 return false;
13 }
14 data[array_b[arrayIndex]] = data[array_b[arrayIndex]] - 1
15 }
16}
17return true
18};

Time Optimized

Time Optimized is Sort and Stringify both Array which is second solution.

Space Optimized

Space Optimized is Brute Force Code solution.

\ No newline at end of file diff --git a/docs/blogs/problems/fibonacci.html b/docs/blogs/problems/fibonacci.html index 4502b43..1f240e3 100644 --- a/docs/blogs/problems/fibonacci.html +++ b/docs/blogs/problems/fibonacci.html @@ -1,7 +1,7 @@ -Fibonacci Series

Fibonacci Series

Aug 7, 202110 mins read

Table of Contents

The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones.

10, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89

History

  1. Leonardo Bonacci, Italian Mathemetician from the Republic of Pisa studied with Muslim schoolmaster who introduced him to the Hindu-Arabic system of Enumeration along with computation. later he investigated various arithmetic sytems in Egypt, France, Greece, Rome and Syria.
  2. In 1202, he published his Liber Abaci (Book of Abacus), Practice of Geometry (1220), Book of Square Numbers (1225) and others etc.
  3. This sequence of numbers (0,1,1,2,3,5,8,13,21,34...) called Fibonacci Sequence which is contraction of Filius Bonacci (son of Bonacci).

Problem of Rabbits

Problem is about a person who has a pair of newborn rabbits (different gender). here problem to determine the numbers of pairs after a year. at the end of each month, a newborn pair grows to maturity.


Rabbits Population per year.

NewbornMaturedTotal
Jan 1101
Feb 1011
Mar 1112
Apr 1123
May 1235
Jun 1358
Jul 15813
Aug 181321
Sep 1132134
Oct 1213455
Nov 1345589
Dec 15589144
Jan 189144233

Properties

Finding the great common divisor of F5 = 5 and F6 = 8 is 1. This is due to the fact that only positive integer that divide F5 = 5 are 1 and 5 (denoted as gcd(F5, F6) = 1 likewise, F6 = 8 are 1,2,4 and 8 (denoted as gcd(F9, F10) = 1) there are common properties available. lets look at them.

  1. For n>=0, GCD(Fn, Fn+1) = 1
  2. For n>=0, GCD(Fn, Fn+2) = 1
  3. Sum of any six consecutive fibonacci numbers is divisible by 4
  4. Sum of 10 consecutive fibonacci numbers is divisible by 11
  5. and there is five more properties until 9.

Solutions

Let's take a problem to find a N-th value of the Fibonacci sequence? +Fibonacci Series

Fibonacci Series

Aug 7, 202110 mins read

Table of Contents

The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones.

10, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89

History

  1. Leonardo Bonacci, Italian Mathemetician from the Republic of Pisa studied with Muslim schoolmaster who introduced him to the Hindu-Arabic system of Enumeration along with computation. later he investigated various arithmetic sytems in Egypt, France, Greece, Rome and Syria.
  2. In 1202, he published his Liber Abaci (Book of Abacus), Practice of Geometry (1220), Book of Square Numbers (1225) and others etc.
  3. This sequence of numbers (0,1,1,2,3,5,8,13,21,34...) called Fibonacci Sequence which is contraction of Filius Bonacci (son of Bonacci).

Problem of Rabbits

Problem is about a person who has a pair of newborn rabbits (different gender). here problem to determine the numbers of pairs after a year. at the end of each month, a newborn pair grows to maturity.


Rabbits Population per year.

NewbornMaturedTotal
Jan 1101
Feb 1011
Mar 1112
Apr 1123
May 1235
Jun 1358
Jul 15813
Aug 181321
Sep 1132134
Oct 1213455
Nov 1345589
Dec 15589144
Jan 189144233

Properties

Finding the great common divisor of F5 = 5 and F6 = 8 is 1. This is due to the fact that only positive integer that divide F5 = 5 are 1 and 5 (denoted as gcd(F5, F6) = 1 likewise, F6 = 8 are 1,2,4 and 8 (denoted as gcd(F9, F10) = 1) there are common properties available. lets look at them.

  1. For n>=0, GCD(Fn, Fn+1) = 1
  2. For n>=0, GCD(Fn, Fn+2) = 1
  3. Sum of any six consecutive fibonacci numbers is divisible by 4
  4. Sum of 10 consecutive fibonacci numbers is divisible by 11
  5. and there is five more properties until 9.

Solutions

Let's take a problem to find a N-th value of the Fibonacci sequence? There is various kinds of approaches in order to get this sequence and there is many solutions available. lets see each of them with solutions written in javascript. Before, lets look at the formulae.

  1. F0 = 0, F1 = 1 (initial conditions)
  2. Fn = Fn-1 + Fn-2, n>=2 (Recurrence Relation)

1. Recursive Approach

Basically, this approach call itself creating more and more branches of the tree until it hits the base case. Below is the recursive solution in Javascript.

Time Complexity: O(2n) - Exponential
Space Complexity: O(n) - Linear (considering function call stack size, otherwise O(1) Constant.)
1function fib_1(n) {
2 if (n < 2) {
3 return n
4 }
5 return fib_1(n - 1) + fib_1(n - 2)
6}

2. Dynamic Programming

  1. Dynamic Programming is mainly an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for same inputs, we can optimize it using Dynamic Programming.
  2. The idea is to simply store the results of sub problems to prevent re-computations of same inputs.
  3. This helps to reduces time complexities from exponential to polynomial.

Time Complexity: O(n).
Space Complexity: O(1).

1function fib_2(n) {
2 let a = 0, b = 1, c, i;
3 if (n == 0)
4 return a;
5 for (i = 2; i <= n; i++) {
6 c = a + b;
7 a = b;
8 b = c;
9 }
10 return b;
11}

3. Power of Matrix Approach

Time Complexity: O(Logn).
Space Complexity: O(1) or O(Logn) on function call stack size consideration.

1function fib_3(n) {
2 const F = [[1, 1], [1, 0]];
3 if (n == 0)
4 return 0;
5 power(F, n - 1);
6 return F[0][0];
7}
8// Helper function that multiplies 2
9// matrices F and M of size 2*2, and
10// puts the multiplication result
11// back to F[][]
12function multiply(F, M) {
13 const x = F[0][0] * M[0][0] + F[0][1] * M[1][0];
14 const y = F[0][0] * M[0][1] + F[0][1] * M[1][1];
15 const z = F[1][0] * M[0][0] + F[1][1] * M[1][0];
16 const w = F[1][0] * M[0][1] + F[1][1] * M[1][1];
17 F[0][0] = x;
18 F[0][1] = y;
19 F[1][0] = z;
20 F[1][1] = w;
21}
22// Helper function that calculates F[][]
23// raise to the power n and puts the
24// result in F[][]
25function power(F, n) {
26 const M = [[1, 1], [1, 0]];
27 // n - 1 times multiply the
28 // matrix to {{1,0},{0,1}}
29 for (let i = 2; i <= n; i++)
30 multiply(F, M);
31}
32// Optimized version of power() in method 4 */
33function power(F, n) {
34 if (n == 0 || n == 1)
35 return;
36 const M = [[1, 1], [1, 0]];
37 power(F, n / 2);
38 multiply(F, F);
39 if (n % 2 != 0)
40 multiply(F, M);
41}

4 Using Binet's Formula

Binet formula, sums, combinatorial representations and generating function of the generalized Fibonacci -numbers.

Time Complexity: O(logn), this is because calculating phi^n takes logn time.
-Space Complexity: O(1)

1function fib_4(n) {
2 let phi = (1 + Math.sqrt(5)) / 2;
3 return Math.round(Math.pow(phi, n) / Math.sqrt(5));
4}

Other Facts

Let's look at the other facts where we used in real life.

Planets Activity

Even our planet activities like Rotations period, Precession Period, Orbital Period are in fibonacci. Refer to Journal of Astronomy on Modeling Celestial Mechanics Using the Fibonacci Numbers

Golden Ratio (Phi)

In mathematics, two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities where F(n+1) / Fn is most of the time is 1.618

Golden ratio everywhere like example below.

  1. Flower petals
  2. Spiral of Pine Cone, Pineapple
  3. Storms spin in golden sequence
  4. Wave can be measured in this ratio.
  5. Planet alignment and spirals of our Milky way galaxy
  6. Shoulder to elbow and elbow to fingertips will be 1:1.6
  7. Finger tips to wrist and wrist to elbow
  8. bottom of fingertips to wrist
  9. Even your ears, brains, lungs system even helix of our DNA that forms rhythm of our hearbeat.
  10. Musical scales like piano.

Fibonacci Extension

Fibonacci extensions are a tool that traders can use to establish profit targets or estimate how far a price may travel after a retracement/pullback is finished. Extension levels are also possible areas where the price may reverse.

Fibonacci Retracement

In finance, Fibonacci retracement is a method of technical analysis for determining support and resistance levels.[1] They are named after their use of the Fibonacci sequence.

\ No newline at end of file +Space Complexity: O(1)

1function fib_4(n) {
2 let phi = (1 + Math.sqrt(5)) / 2;
3 return Math.round(Math.pow(phi, n) / Math.sqrt(5));
4}

Other Facts

Let's look at the other facts where we used in real life.

Planets Activity

Even our planet activities like Rotations period, Precession Period, Orbital Period are in fibonacci. Refer to Journal of Astronomy on Modeling Celestial Mechanics Using the Fibonacci Numbers

Golden Ratio (Phi)

In mathematics, two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities where F(n+1) / Fn is most of the time is 1.618

Golden ratio everywhere like example below.

  1. Flower petals
  2. Spiral of Pine Cone, Pineapple
  3. Storms spin in golden sequence
  4. Wave can be measured in this ratio.
  5. Planet alignment and spirals of our Milky way galaxy
  6. Shoulder to elbow and elbow to fingertips will be 1:1.6
  7. Finger tips to wrist and wrist to elbow
  8. bottom of fingertips to wrist
  9. Even your ears, brains, lungs system even helix of our DNA that forms rhythm of our hearbeat.
  10. Musical scales like piano.

Fibonacci Extension

Fibonacci extensions are a tool that traders can use to establish profit targets or estimate how far a price may travel after a retracement/pullback is finished. Extension levels are also possible areas where the price may reverse.

Fibonacci Retracement

In finance, Fibonacci retracement is a method of technical analysis for determining support and resistance levels.[1] They are named after their use of the Fibonacci sequence.

\ No newline at end of file diff --git a/docs/blogs/problems/missing-element-in-permutation.html b/docs/blogs/problems/missing-element-in-permutation.html index c6b5be0..6a883e1 100644 --- a/docs/blogs/problems/missing-element-in-permutation.html +++ b/docs/blogs/problems/missing-element-in-permutation.html @@ -1 +1 @@ -Missing element in Permutation.

Missing element in Permutation.

Jul 21, 20202 mins read

An array A consisting of N different integers is given. The array contains integers in the range [1..(N + 1)], which means that exactly one element is missing.

Your goal is to find that missing element.

Write a function:

1function solution(A) {
2}

that, given an array A, returns the value of the missing element.

For example, given array A such that:

  • A[0] = 2
  • A[1] = 3
  • A[2] = 1
  • A[3] = 5

the function should return 4, as it is the missing element.

Write an efficient algorithm for the following assumptions:

  • N is an integer within the range [0..100,000];
  • the elements of A are all distinct;
  • each element of array A is an integer within the range [1..(N + 1)].

Points to be Taken

1.1

1function solution(A) {
2 const b = A.sort()
3 for(let i=0;i<=b.length;i++) {
4 if(b[i+1] !== b[i] + 1) {
5 return b[i] + 1
6 }
7 }
8 return ''
9}

1.2

1function solution(A) {
2 const n = A.length + 1
3 const sumOfN = Math.floor(n * (n + 1) / 2)
4 const sumOfAll = A.reduce((a, b) => a + b, 0)
5 return sumOfN - sumOfAll
6}

Points to be Taken

  1. Array problem expect empty array condition check and single element check.
  2. Arithmetic progression
\ No newline at end of file +Missing element in Permutation.

Missing element in Permutation.

Jul 21, 20202 mins read

An array A consisting of N different integers is given. The array contains integers in the range [1..(N + 1)], which means that exactly one element is missing.

Your goal is to find that missing element.

Write a function:

1function solution(A) {
2}

that, given an array A, returns the value of the missing element.

For example, given array A such that:

  • A[0] = 2
  • A[1] = 3
  • A[2] = 1
  • A[3] = 5

the function should return 4, as it is the missing element.

Write an efficient algorithm for the following assumptions:

  • N is an integer within the range [0..100,000];
  • the elements of A are all distinct;
  • each element of array A is an integer within the range [1..(N + 1)].

Points to be Taken

1.1

1function solution(A) {
2 const b = A.sort()
3 for(let i=0;i<=b.length;i++) {
4 if(b[i+1] !== b[i] + 1) {
5 return b[i] + 1
6 }
7 }
8 return ''
9}

1.2

1function solution(A) {
2 const n = A.length + 1
3 const sumOfN = Math.floor(n * (n + 1) / 2)
4 const sumOfAll = A.reduce((a, b) => a + b, 0)
5 return sumOfN - sumOfAll
6}

Points to be Taken

  1. Array problem expect empty array condition check and single element check.
  2. Arithmetic progression
\ No newline at end of file diff --git a/docs/blogs/problems/palindrome.html b/docs/blogs/problems/palindrome.html index d20c15c..14d32be 100644 --- a/docs/blogs/problems/palindrome.html +++ b/docs/blogs/problems/palindrome.html @@ -1,2 +1,2 @@ -Palindrome Solutions

Palindrome Solutions

Jul 21, 20202 mins read

Table of Contents

PALINDROMES means PALIN (Back again) and DROMES (Running) -Single Character is palindromic string.

History

  1. Palindrome comes from ancient greek
  2. Sator Square is one of the famous piece which is two dimensional

Below is the basic coding solution written in javascript.

1function isPalindrome(S) {
2 let iteration = Math.round(S.length / 2);
3 let backward = S.length;
4 for (let forward = 0; forward < iteration; forward++) {
5 backward--;
6 if (S[forward].toLowerCase() !== S[backward].toLowerCase()) {
7 return "NO";
8 }
9 }
10 return "YES";
11}

Some Words

  1. Detartrated (Longest incidental palindrome)
  2. WOW
  3. KAYAK
  4. Symmys - (Annual awards)
  5. RADAR
  6. EVIL OLIVE
  7. TACO CAT
  8. HUH
  9. DO GEESE SEE GOD
  10. BORE ME ROB
  11. RISE SIR
  12. MADAM
  13. DIVE VID
  14. Tattarrattat (Sound of knocking at the door used by James Joyce in Ulysses, modernist novel)

Some Phrases

  1. Top spot
  2. Able was i ere I Saw Elba
  3. A man, A Plan, A Canal: Panama

Longest Palindromic Substring

xyxracecart

\ No newline at end of file +Palindrome Solutions

Palindrome Solutions

Jul 21, 20202 mins read

Table of Contents

PALINDROMES means PALIN (Back again) and DROMES (Running) +Single Character is palindromic string.

History

  1. Palindrome comes from ancient greek
  2. Sator Square is one of the famous piece which is two dimensional

Below is the basic coding solution written in javascript.

1function isPalindrome(S) {
2 let iteration = Math.round(S.length / 2);
3 let backward = S.length;
4 for (let forward = 0; forward < iteration; forward++) {
5 backward--;
6 if (S[forward].toLowerCase() !== S[backward].toLowerCase()) {
7 return "NO";
8 }
9 }
10 return "YES";
11}

Some Words

  1. Detartrated (Longest incidental palindrome)
  2. WOW
  3. KAYAK
  4. Symmys - (Annual awards)
  5. RADAR
  6. EVIL OLIVE
  7. TACO CAT
  8. HUH
  9. DO GEESE SEE GOD
  10. BORE ME ROB
  11. RISE SIR
  12. MADAM
  13. DIVE VID
  14. Tattarrattat (Sound of knocking at the door used by James Joyce in Ulysses, modernist novel)

Some Phrases

  1. Top spot
  2. Able was i ere I Saw Elba
  3. A man, A Plan, A Canal: Panama

Longest Palindromic Substring

xyxracecart

\ No newline at end of file diff --git a/docs/blogs/problems/simple-frog-jump.html b/docs/blogs/problems/simple-frog-jump.html index 2c7730e..c22dcc7 100644 --- a/docs/blogs/problems/simple-frog-jump.html +++ b/docs/blogs/problems/simple-frog-jump.html @@ -1 +1 @@ -Frog Jump Solution

Frog Jump Solution

Jul 21, 20202 mins read

A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D.

Count the minimal number of jumps that the small frog must perform to reach its target.

Write a function:

1function solution(X, Y, D) {
2 // write your code in JavaScript (Node.js 8.9.4)
3}

that, given three integers X, Y and D, returns the minimal number of jumps from position X to a position equal to or greater than Y.

For example, given:

  • X = 10
  • Y = 85
  • D = 30

the function should return 3, because the frog will be positioned as follows:

  • after the first jump, at position 10 + 30 = 40
  • after the second jump, at position 10 + 30 + 30 = 70
  • after the third jump, at position 10 + 30 + 30 + 30 = 100

Write an efficient algorithm for the following assumptions:

  • X, Y and D are integers within the range [1..1,000,000,000];
  • X ≤ Y.
1function solution(x, y, d) {
2 // write your code in JavaScript (Node.js 8.9.4)
3 if ((y - x) % d === 0) {
4 return (y - x) / d;
5 }
6 return Math.ceil((y - x) / d);
7}

Points to be Taken

  1. Solution need division check with modulo operator whether its remainder is zero.
\ No newline at end of file +Frog Jump Solution

Frog Jump Solution

Jul 21, 20202 mins read

A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D.

Count the minimal number of jumps that the small frog must perform to reach its target.

Write a function:

1function solution(X, Y, D) {
2 // write your code in JavaScript (Node.js 8.9.4)
3}

that, given three integers X, Y and D, returns the minimal number of jumps from position X to a position equal to or greater than Y.

For example, given:

  • X = 10
  • Y = 85
  • D = 30

the function should return 3, because the frog will be positioned as follows:

  • after the first jump, at position 10 + 30 = 40
  • after the second jump, at position 10 + 30 + 30 = 70
  • after the third jump, at position 10 + 30 + 30 + 30 = 100

Write an efficient algorithm for the following assumptions:

  • X, Y and D are integers within the range [1..1,000,000,000];
  • X ≤ Y.
1function solution(x, y, d) {
2 // write your code in JavaScript (Node.js 8.9.4)
3 if ((y - x) % d === 0) {
4 return (y - x) / d;
5 }
6 return Math.ceil((y - x) / d);
7}

Points to be Taken

  1. Solution need division check with modulo operator whether its remainder is zero.
\ No newline at end of file diff --git a/docs/blogs/problems/tape-equilibrium.html b/docs/blogs/problems/tape-equilibrium.html index 6e79009..d07b7b0 100644 --- a/docs/blogs/problems/tape-equilibrium.html +++ b/docs/blogs/problems/tape-equilibrium.html @@ -1 +1 @@ -Tape Equilibrium

Tape Equilibrium

Jul 21, 20202 mins read

Table of Contents

PALINDROMES means PALIN (Back again) and DROMES (Running)

History

  1. Palindrome comes from ancient greek
  2. Sator Square is one of the famous piece which is two dimensional

Below is the basic coding solution written in javascript.

1function isPalindrome(S) {
2 let iteration = Math.round(S.length / 2);
3 let backward = S.length;
4 for (let forward = 0; forward < iteration; forward++) {
5 backward--;
6 if (S[forward].toLowerCase() !== S[backward].toLowerCase()) {
7 return "NO";
8 }
9 }
10 return "YES";
11}

Some Words

  1. Detartrated (Longest incidental palindrome)
  2. WOW
  3. KAYAK
  4. Symmys - (Annual awards)
  5. RADAR
  6. EVIL OLIVE
  7. TACO CAT
  8. HUH
  9. DO GEESE SEE GOD
  10. BORE ME ROB
  11. RISE SIR
  12. MADAM
  13. DIVE VID
  14. Tattarrattat (Sound of knocking at the door used by James Joyce in Ulysses, modernist novel)

Some Phrases

  1. Top spot
  2. Able was i ere I Saw Elba
  3. A man, A Plan, A Canal: Panama
\ No newline at end of file +Tape Equilibrium

Tape Equilibrium

Jul 21, 20202 mins read

Table of Contents

PALINDROMES means PALIN (Back again) and DROMES (Running)

History

  1. Palindrome comes from ancient greek
  2. Sator Square is one of the famous piece which is two dimensional

Below is the basic coding solution written in javascript.

1function isPalindrome(S) {
2 let iteration = Math.round(S.length / 2);
3 let backward = S.length;
4 for (let forward = 0; forward < iteration; forward++) {
5 backward--;
6 if (S[forward].toLowerCase() !== S[backward].toLowerCase()) {
7 return "NO";
8 }
9 }
10 return "YES";
11}

Some Words

  1. Detartrated (Longest incidental palindrome)
  2. WOW
  3. KAYAK
  4. Symmys - (Annual awards)
  5. RADAR
  6. EVIL OLIVE
  7. TACO CAT
  8. HUH
  9. DO GEESE SEE GOD
  10. BORE ME ROB
  11. RISE SIR
  12. MADAM
  13. DIVE VID
  14. Tattarrattat (Sound of knocking at the door used by James Joyce in Ulysses, modernist novel)

Some Phrases

  1. Top spot
  2. Able was i ere I Saw Elba
  3. A man, A Plan, A Canal: Panama
\ No newline at end of file diff --git a/docs/blogs/programming.html b/docs/blogs/programming.html index f68179d..394d060 100644 --- a/docs/blogs/programming.html +++ b/docs/blogs/programming.html @@ -1 +1 @@ -Webslate.io - Programming

10 Things you should know

10 Things you should know

Jul 21, 20202 mins read
Read more →
\ No newline at end of file +Webslate.io - Programming

10 Things you should know

10 Things you should know

Jul 21, 20202 mins read
Read more →
\ No newline at end of file diff --git a/docs/blogs/programming/10-things-should-know.html b/docs/blogs/programming/10-things-should-know.html index e78619b..d6bb501 100644 --- a/docs/blogs/programming/10-things-should-know.html +++ b/docs/blogs/programming/10-things-should-know.html @@ -1 +1 @@ -10 Things you should know

10 Things you should know

Jul 21, 20202 mins read

10 Things you should know

\ No newline at end of file +10 Things you should know

10 Things you should know

Jul 21, 20202 mins read

10 Things you should know

\ No newline at end of file diff --git a/docs/blogs/react.html b/docs/blogs/react.html index 2409fc5..ef1fb37 100644 --- a/docs/blogs/react.html +++ b/docs/blogs/react.html @@ -1 +1 @@ -Webslate.io - React Articles

useEffect Basics (Part 1)

One of the good Features in React 16.x

Jul 21, 20202 mins read
Read more →
\ No newline at end of file +Webslate.io - React Articles

useEffect Basics (Part 1)

One of the good Features in React 16.x

Jul 21, 20202 mins read
Read more →
\ No newline at end of file diff --git a/docs/blogs/react/use-effect.html b/docs/blogs/react/use-effect.html index 198705d..b9d61d9 100644 --- a/docs/blogs/react/use-effect.html +++ b/docs/blogs/react/use-effect.html @@ -1 +1 @@ -useEffect Basics (Part 1)

useEffect Basics (Part 1)

Jul 21, 20202 mins read

Welcome to useEffect basics article

\ No newline at end of file +useEffect Basics (Part 1)

useEffect Basics (Part 1)

Jul 21, 20202 mins read

Welcome to useEffect basics article

\ No newline at end of file diff --git a/docs/blogs/security.html b/docs/blogs/security.html index 68bc05f..52fc02f 100644 --- a/docs/blogs/security.html +++ b/docs/blogs/security.html @@ -1 +1 @@ -Webslate.io - Security Articles

Preventing SSRF Attacks

Tricks to preventing SSRF Attacks

Jul 21, 20202 mins read
Read more →
\ No newline at end of file +Webslate.io - Security Articles

Preventing SSRF Attacks

Tricks to preventing SSRF Attacks

Jul 21, 20202 mins read
Read more →
\ No newline at end of file diff --git a/docs/blogs/security/prevent-ssrf-attacks.html b/docs/blogs/security/prevent-ssrf-attacks.html index 3e3c6f5..95a754d 100644 --- a/docs/blogs/security/prevent-ssrf-attacks.html +++ b/docs/blogs/security/prevent-ssrf-attacks.html @@ -1,2 +1,2 @@ -Preventing SSRF Attacks

Preventing SSRF Attacks

Jul 21, 20202 mins read

SSRF

SSRF stands for Server-Side Request Forgery. Its one type of exploit to server where hacker attempts to gather user information by various way in functionality which is not recommended.

Types

There are mainly two types.

  1. Basic SSRF - Server accept the attacker request and respond.
  2. Blind SSRF - Server

Subjects

We have two subjects.

  1. Attacker / Hacker - Their motives can be money, info or get paid service for free.
  2. Vulnerable App - App accepts invalid URLs or params.

Solutions

  1. Whitelisting

Questions

  1. What is difference between CSRF and SSRF? -CSRF attack user and browser where SSRF target server directly.
\ No newline at end of file +Preventing SSRF Attacks

Preventing SSRF Attacks

Jul 21, 20202 mins read

SSRF

SSRF stands for Server-Side Request Forgery. Its one type of exploit to server where hacker attempts to gather user information by various way in functionality which is not recommended.

Types

There are mainly two types.

  1. Basic SSRF - Server accept the attacker request and respond.
  2. Blind SSRF - Server

Subjects

We have two subjects.

  1. Attacker / Hacker - Their motives can be money, info or get paid service for free.
  2. Vulnerable App - App accepts invalid URLs or params.

Solutions

  1. Whitelisting

Questions

  1. What is difference between CSRF and SSRF? +CSRF attack user and browser where SSRF target server directly.
\ No newline at end of file diff --git a/docs/coming-soon.html b/docs/coming-soon.html index 23d8e4c..df8e64c 100644 --- a/docs/coming-soon.html +++ b/docs/coming-soon.html @@ -1 +1 @@ -Webslate - Coming Soon...

Thanks for visiting this page. Its coming soon...

Web Slate.io
\ No newline at end of file +Webslate - Coming Soon...

Thanks for visiting this page. Its coming soon...

Web Slate.io
\ No newline at end of file diff --git a/docs/index.html b/docs/index.html index d70858b..73e52de 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1 +1 @@ -Welcome to Webslate \ No newline at end of file +Welcome to Webslate \ No newline at end of file diff --git a/docs/styles/global.css b/docs/styles/global.css index 2aa5af9..7a48486 100644 --- a/docs/styles/global.css +++ b/docs/styles/global.css @@ -33,4 +33,8 @@ table thead tr th { } table thead tr th, table tbody tr td { padding: 5px 10px; +} + +.token-line:not(:last-child) { + min-height: 1rem; } \ No newline at end of file diff --git a/src/package-lock.json b/src/package-lock.json index 02d8d51..1e325af 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -1,6 +1,6 @@ { "name": "src", - "version": "1.2.3", + "version": "1.2.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/package.json b/src/package.json index d1d131b..c75ccc1 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "webslate", - "version": "1.2.3", + "version": "1.2.4", "description": "", "main": "index.js", "scripts": { diff --git a/src/pages/blogs/data-structures/stack.mdx b/src/pages/blogs/data-structures/stack.mdx index ca4c684..a69cf9f 100644 --- a/src/pages/blogs/data-structures/stack.mdx +++ b/src/pages/blogs/data-structures/stack.mdx @@ -59,31 +59,25 @@ Below is the simple example in JavaScript. function Stack() { let count = 0; const storage = {}; - const push = (value) => { storage[count] = value; count++; } - const pop = () => { if(count === 0) { return undefined; } - count--; const lastValue = storage[count]; delete storage[count] return lastValue; } - const size = () => { return count; } - const peek = () => { return storage[count-1] } - return { push, pop, @@ -91,7 +85,7 @@ function Stack() { peek } } -`.trim()} +`} ## Below is the complexity table for Stack.