[{"data":1,"prerenderedAt":2777},["ShallowReactive",2],{"collection-ehfolder":3},{"posts":4,"series":2756},[5,96,486,752,773,896,926,1119,1402,1888,2062,2093,2127,2158,2230,2643],{"id":6,"title":7,"author":8,"body":9,"date":78,"description":79,"draft":80,"extension":81,"image":82,"language":83,"meta":84,"navigation":85,"part":86,"path":87,"readingTime":88,"seo":89,"series":90,"stem":91,"tags":92,"__hash__":95},"blog\u002Fblog\u002FCode Log - Day 0.md","Code Log - Day 0","Caio Prado",{"type":10,"value":11,"toc":72},"minimark",[12,17,21,25,28,69],[13,14,16],"h2",{"id":15},"the-challenge","The Challenge",[18,19,20],"p",{},"It consists in daily coding practice, where i'm going to dedicate part of my day do produce programming related stuff, like solving some code online judges exercises or working on a side project.",[13,22,24],{"id":23},"in-practice","In Practice",[18,26,27],{},"To start, i'll be doing LeetCode exercises and working on some unfinished projects:",[29,30,31,41,48,55,62],"ul",{},[32,33,34],"li",{},[35,36,40],"a",{"href":37,"rel":38},"https:\u002F\u002Fgithub.com\u002Fcaioopr\u002Fsecond_brain",[39],"nofollow","Second Brain",[32,42,43],{},[35,44,47],{"href":45,"rel":46},"https:\u002F\u002Fgithub.com\u002Fcaioopr\u002Fixtore",[39],"Ixtore",[32,49,50],{},[35,51,54],{"href":52,"rel":53},"https:\u002F\u002Fgithub.com\u002Fcaioopr\u002Fproductivist_ecosystem",[39],"Productivist Ecosystem",[32,56,57],{},[35,58,61],{"href":59,"rel":60},"https:\u002F\u002Fgithub.com\u002Fcaioopr\u002Flibrary_management_systems",[39],"Library Management System",[32,63,64],{},[35,65,68],{"href":66,"rel":67},"https:\u002F\u002Fgithub.com\u002Fcaioopr\u002FMiahbits",[39],"Miahbits",[18,70,71],{},"After these, if i'm still unemployed, i'll be focusing on writing data structures\u002Falgorithms and design patterns implementations, and starting new projects.",{"title":73,"searchDepth":74,"depth":74,"links":75},"",2,[76,77],{"id":15,"depth":74,"text":16},{"id":23,"depth":74,"text":24},"2025-01-06","Starting a daily coding challenge, the unfinished side projects I'll pick back up, and the rules I set for myself.",false,"md",null,"en",{},true,0,"\u002Fblog\u002Fcode-log-day-0",1,{"title":7,"description":79},"code-log","blog\u002FCode Log - Day 0",[93,94],"challenge","daily-coding","h2O6-MbdHLpOEW4S769vvGOsgRM0cXoQYFDetz9UoOc",{"id":97,"title":98,"author":8,"body":99,"date":477,"description":478,"draft":80,"extension":81,"image":82,"language":83,"meta":479,"navigation":85,"part":88,"path":480,"readingTime":175,"seo":481,"series":90,"stem":482,"tags":483,"__hash__":485},"blog\u002Fblog\u002FCode Log - Day 1.md","Code Log - Day 1",{"type":10,"value":100,"toc":471},[101,105,108,113,116,144,153,292,303,418,421,425,467],[13,102,104],{"id":103},"log","Log",[18,106,107],{},"Today i decided to solve a LeetCode exercise and work on a side project open issues.",[109,110,112],"h3",{"id":111},"leetcode","LeetCode",[18,114,115],{},"Since there is a bit of time from the last time i solved a LeetCode exercise a chose easy one: Remove Element.\nIt requires a function that receive as input an array of integers numbers and a value to remove all occurrences of the value \"in-place\" and to return the number of the elements in the array that are not equal to the value:",[117,118,119],"blockquote",{},[18,120,121,122,126,127,130,131,133,134,137,138,140,141,143],{},"Change the array ",[123,124,125],"code",{},"nums"," such that the first ",[123,128,129],{},"k"," elements of ",[123,132,125],{}," contain the elements which are not equal to ",[123,135,136],{},"val",". The remaining elements of ",[123,139,125],{}," are not important as well as the size of ",[123,142,125],{},".",[18,145,146,147,149,150,152],{},"My first approach to achieve this was to put the elements that are equal at the end of the ",[123,148,125],{}," array. However, since the only thing that actually matters is the first ",[123,151,129],{}," elements, this solution ends up not being the best one.",[154,155,159],"pre",{"className":156,"code":157,"language":158,"meta":73,"style":73},"language-java shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","class Solution {\n    public int removeElement(int[] nums, int val) {\n\n        int val_occurrences = 0;\n        int nums_len = nums.length - 1;\n        for(int i=0, j=nums_len ; i\u003C=j ;i++){\n            if(nums[i] == val){\n                while(i!=j && nums[j] == val){\n                   val_occurrences++;\n                    j--;\n                }\n                int temp = nums[i];\n                nums[i] = nums[j];\n                nums[j] = temp;\n                val_occurrences++;\n                j--;\n\n            }\n        }\n        return nums.length - val_occurrences;\n    }\n}\n","java",[123,160,161,168,173,179,185,191,197,203,209,215,221,227,233,239,245,251,257,262,268,274,280,286],{"__ignoreMap":73},[162,163,165],"span",{"class":164,"line":88},"line",[162,166,167],{},"class Solution {\n",[162,169,170],{"class":164,"line":74},[162,171,172],{},"    public int removeElement(int[] nums, int val) {\n",[162,174,176],{"class":164,"line":175},3,[162,177,178],{"emptyLinePlaceholder":85},"\n",[162,180,182],{"class":164,"line":181},4,[162,183,184],{},"        int val_occurrences = 0;\n",[162,186,188],{"class":164,"line":187},5,[162,189,190],{},"        int nums_len = nums.length - 1;\n",[162,192,194],{"class":164,"line":193},6,[162,195,196],{},"        for(int i=0, j=nums_len ; i\u003C=j ;i++){\n",[162,198,200],{"class":164,"line":199},7,[162,201,202],{},"            if(nums[i] == val){\n",[162,204,206],{"class":164,"line":205},8,[162,207,208],{},"                while(i!=j && nums[j] == val){\n",[162,210,212],{"class":164,"line":211},9,[162,213,214],{},"                   val_occurrences++;\n",[162,216,218],{"class":164,"line":217},10,[162,219,220],{},"                    j--;\n",[162,222,224],{"class":164,"line":223},11,[162,225,226],{},"                }\n",[162,228,230],{"class":164,"line":229},12,[162,231,232],{},"                int temp = nums[i];\n",[162,234,236],{"class":164,"line":235},13,[162,237,238],{},"                nums[i] = nums[j];\n",[162,240,242],{"class":164,"line":241},14,[162,243,244],{},"                nums[j] = temp;\n",[162,246,248],{"class":164,"line":247},15,[162,249,250],{},"                val_occurrences++;\n",[162,252,254],{"class":164,"line":253},16,[162,255,256],{},"                j--;\n",[162,258,260],{"class":164,"line":259},17,[162,261,178],{"emptyLinePlaceholder":85},[162,263,265],{"class":164,"line":264},18,[162,266,267],{},"            }\n",[162,269,271],{"class":164,"line":270},19,[162,272,273],{},"        }\n",[162,275,277],{"class":164,"line":276},20,[162,278,279],{},"        return nums.length - val_occurrences;\n",[162,281,283],{"class":164,"line":282},21,[162,284,285],{},"    }\n",[162,287,289],{"class":164,"line":288},22,[162,290,291],{},"}\n",[18,293,294,295,297,298,143],{},"An alternative and better approach, with 0.2 MB less memory usage compared with the first solution, only worry about placing the different values together at the beginning of ",[123,296,125],{}," by keeping an index\u002Fcount to these values, and can be found ",[35,299,302],{"href":300,"rel":301},"https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fremove-element\u002Fsolutions\u002F3670940\u002Fbest-100-c-java-python-beginner-friendly\u002F",[39],"here",[154,304,306],{"className":156,"code":305,"language":158,"meta":73,"style":73},"class Solution {\n    public int removeElement(int[] nums, int val) {\n\n        int last_diff_val = 0;\n        for(int i = 0; i\u003Cnums.length; i++){\n            if(nums[i] != val){\n                nums[last_diff_val] = nums[i];\n                last_diff_val++;\n            }\n        }\n\n        \u002F*\n        \u002F\u002F this ways has a more clean read but uses more memory\n        for(int num_i : nums){\n            if(num_i != val){\n                nums[last_diff_val] = num_i;\n                last_diff_val++;\n            }\n        }\n        *\u002F\n\n        return last_diff_val;\n    }\n}\n",[123,307,308,312,316,320,325,330,335,340,345,349,353,357,362,367,372,377,382,386,390,394,399,403,408,413],{"__ignoreMap":73},[162,309,310],{"class":164,"line":88},[162,311,167],{},[162,313,314],{"class":164,"line":74},[162,315,172],{},[162,317,318],{"class":164,"line":175},[162,319,178],{"emptyLinePlaceholder":85},[162,321,322],{"class":164,"line":181},[162,323,324],{},"        int last_diff_val = 0;\n",[162,326,327],{"class":164,"line":187},[162,328,329],{},"        for(int i = 0; i\u003Cnums.length; i++){\n",[162,331,332],{"class":164,"line":193},[162,333,334],{},"            if(nums[i] != val){\n",[162,336,337],{"class":164,"line":199},[162,338,339],{},"                nums[last_diff_val] = nums[i];\n",[162,341,342],{"class":164,"line":205},[162,343,344],{},"                last_diff_val++;\n",[162,346,347],{"class":164,"line":211},[162,348,267],{},[162,350,351],{"class":164,"line":217},[162,352,273],{},[162,354,355],{"class":164,"line":223},[162,356,178],{"emptyLinePlaceholder":85},[162,358,359],{"class":164,"line":229},[162,360,361],{},"        \u002F*\n",[162,363,364],{"class":164,"line":235},[162,365,366],{},"        \u002F\u002F this ways has a more clean read but uses more memory\n",[162,368,369],{"class":164,"line":241},[162,370,371],{},"        for(int num_i : nums){\n",[162,373,374],{"class":164,"line":247},[162,375,376],{},"            if(num_i != val){\n",[162,378,379],{"class":164,"line":253},[162,380,381],{},"                nums[last_diff_val] = num_i;\n",[162,383,384],{"class":164,"line":259},[162,385,344],{},[162,387,388],{"class":164,"line":264},[162,389,267],{},[162,391,392],{"class":164,"line":270},[162,393,273],{},[162,395,396],{"class":164,"line":276},[162,397,398],{},"        *\u002F\n",[162,400,401],{"class":164,"line":282},[162,402,178],{"emptyLinePlaceholder":85},[162,404,405],{"class":164,"line":288},[162,406,407],{},"        return last_diff_val;\n",[162,409,411],{"class":164,"line":410},23,[162,412,285],{},[162,414,416],{"class":164,"line":415},24,[162,417,291],{},[419,420],"hr",{},[109,422,424],{"id":423},"side-project","Side Project",[18,426,427,428,431,432,435,436,439,440,443,444,447,448,451,452,455,456,447,459,462,463,466],{},"I decided to work on my {Second Brain](",[35,429,37],{"href":37,"rel":430},[39],") project open issues. The issue i closed today was the \"Projects page\" one, where i had to finish the implementation of a page that display links to my projects description pages, just like the \"Posts\" page but for projects.\nIn this project, because i'm using Nuxt.js with the module Nuxt Content, it's really easy to add new pages and sub-pages, just like for the posts and post page it was enough to: add a folder ",[123,433,434],{},"projects"," at ",[123,437,438],{},"\u002Fpages\u002F"," and at ",[123,441,442],{},"\u002Fcontent","; create an ",[123,445,446],{},"index.md"," file at ",[123,449,450],{},"\u002Fcontent\u002Fprojects"," and define the component that will display the projects list with ",[123,453,454],{},"::component-name","; create a ",[123,457,458],{},"[...slug].vue",[123,460,461],{},"\u002Fpages\u002Fprojects"," and define the code responsible to render the single project page when accessing ",[123,464,465],{},"\u002Fprojects\u002Fproject_name"," in the browser.\nThe \"Projects page\" is already working. However , i'll probably be changing the design of the projects list item in the future, maybe add card style with a image preview.",[468,469,470],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":73,"searchDepth":74,"depth":74,"links":472},[473],{"id":103,"depth":74,"text":104,"children":474},[475,476],{"id":111,"depth":175,"text":112},{"id":423,"depth":175,"text":424},"2025-01-07","Solving LeetCode's Remove Element in Java and finishing the Projects page of my Second Brain side project.",{},"\u002Fblog\u002Fcode-log-day-1",{"title":98,"description":478},"blog\u002FCode Log - Day 1",[93,94,111,484],"nuxt.js","jAr9ApxJBGw3RU6fxrFS21AZC98bq7nnNZ38wshkCFs",{"id":487,"title":488,"author":8,"body":489,"date":744,"description":745,"draft":80,"extension":81,"image":82,"language":83,"meta":746,"navigation":85,"part":217,"path":747,"readingTime":74,"seo":748,"series":90,"stem":749,"tags":750,"__hash__":751},"blog\u002Fblog\u002FCode Log - Day 10.md","Code Log - Day 10",{"type":10,"value":490,"toc":738},[491,493,502,504,507,545,552,729,733,736],[13,492,104],{"id":103},[18,494,495,496,501],{},"Today i solved a LeetCode exercise from the ",[35,497,500],{"href":498,"rel":499},"https:\u002F\u002Fleetcode.com\u002Fstudyplan\u002Ftop-interview-150\u002F",[39],"Top 150 Interview Questions"," list and worked on an assignment from my university.",[109,503,112],{"id":111},[18,505,506],{},"The LeetCode exercise i chose was: Remove Duplicates from Sorted Array II.\nIt requires a function that receive as input an integer array to remove in-place the numbers that already appeared more than two times and return the number of numbers left:",[117,508,509],{},[18,510,511,512,514,515,519,520,523,524,527,528,531,532,130,534,536,537,539,540,542,543,143],{},"Given an integer array ",[123,513,125],{}," sorted in ",[516,517,518],"strong",{},"non-decreasing order",", remove some duplicates in-place such that each unique element appears ",[516,521,522],{},"at most twice",". The ",[516,525,526],{},"relative order"," of the elements should be kept the ",[516,529,530],{},"same",". ... the first ",[123,533,129],{},[123,535,125],{}," should hold the final result. Return ",[123,538,129],{}," after placing the final result in the first ",[123,541,129],{}," slots of ",[123,544,125],{},[18,546,547,548,551],{},"The solution was basically the same as the ",[123,549,550],{},"Remove Duplicates from Sorted Array I",", but with a number appearance count check:",[154,553,555],{"className":156,"code":554,"language":158,"meta":73,"style":73},"class Solution {\n\npublic int removeDuplicates(int[] nums) {\n\n    if (\n        nums.length \u003C 1 ||\n        nums.length > 30000 ||\n        nums[0] \u003C -100 ||\n        nums[nums.length - 1] > 100\n    ) return 0;\n\n\n    \u002F\u002F starts with both idx 1 because the minimum arr.len is 1\n    \u002F\u002F and the comparison must be done using the previous number\n    int len = 1;\n    int dups = 0;\n\n    for (int i = 1; i \u003C nums.length; i++) {\n\n        \u002F\u002F compare i with i-1\n        if (nums[i] != nums[i - 1]) {\n            \u002F\u002F nums[len] is the number after the last unique number\n            nums[len] = nums[i];\n            dups = 0;\n            len++;\n        } else if(nums[i] == nums[i - 1] && dups \u003C 1){\n            nums[len] = nums[i];\n            dups++;\n            len++;\n        }\n\n    }\n    return len;\n    }\n}\n",[123,556,557,561,565,570,574,579,584,589,594,599,604,608,612,617,622,627,632,636,641,645,650,655,660,665,670,676,682,687,693,698,703,708,713,719,724],{"__ignoreMap":73},[162,558,559],{"class":164,"line":88},[162,560,167],{},[162,562,563],{"class":164,"line":74},[162,564,178],{"emptyLinePlaceholder":85},[162,566,567],{"class":164,"line":175},[162,568,569],{},"public int removeDuplicates(int[] nums) {\n",[162,571,572],{"class":164,"line":181},[162,573,178],{"emptyLinePlaceholder":85},[162,575,576],{"class":164,"line":187},[162,577,578],{},"    if (\n",[162,580,581],{"class":164,"line":193},[162,582,583],{},"        nums.length \u003C 1 ||\n",[162,585,586],{"class":164,"line":199},[162,587,588],{},"        nums.length > 30000 ||\n",[162,590,591],{"class":164,"line":205},[162,592,593],{},"        nums[0] \u003C -100 ||\n",[162,595,596],{"class":164,"line":211},[162,597,598],{},"        nums[nums.length - 1] > 100\n",[162,600,601],{"class":164,"line":217},[162,602,603],{},"    ) return 0;\n",[162,605,606],{"class":164,"line":223},[162,607,178],{"emptyLinePlaceholder":85},[162,609,610],{"class":164,"line":229},[162,611,178],{"emptyLinePlaceholder":85},[162,613,614],{"class":164,"line":235},[162,615,616],{},"    \u002F\u002F starts with both idx 1 because the minimum arr.len is 1\n",[162,618,619],{"class":164,"line":241},[162,620,621],{},"    \u002F\u002F and the comparison must be done using the previous number\n",[162,623,624],{"class":164,"line":247},[162,625,626],{},"    int len = 1;\n",[162,628,629],{"class":164,"line":253},[162,630,631],{},"    int dups = 0;\n",[162,633,634],{"class":164,"line":259},[162,635,178],{"emptyLinePlaceholder":85},[162,637,638],{"class":164,"line":264},[162,639,640],{},"    for (int i = 1; i \u003C nums.length; i++) {\n",[162,642,643],{"class":164,"line":270},[162,644,178],{"emptyLinePlaceholder":85},[162,646,647],{"class":164,"line":276},[162,648,649],{},"        \u002F\u002F compare i with i-1\n",[162,651,652],{"class":164,"line":282},[162,653,654],{},"        if (nums[i] != nums[i - 1]) {\n",[162,656,657],{"class":164,"line":288},[162,658,659],{},"            \u002F\u002F nums[len] is the number after the last unique number\n",[162,661,662],{"class":164,"line":410},[162,663,664],{},"            nums[len] = nums[i];\n",[162,666,667],{"class":164,"line":415},[162,668,669],{},"            dups = 0;\n",[162,671,673],{"class":164,"line":672},25,[162,674,675],{},"            len++;\n",[162,677,679],{"class":164,"line":678},26,[162,680,681],{},"        } else if(nums[i] == nums[i - 1] && dups \u003C 1){\n",[162,683,685],{"class":164,"line":684},27,[162,686,664],{},[162,688,690],{"class":164,"line":689},28,[162,691,692],{},"            dups++;\n",[162,694,696],{"class":164,"line":695},29,[162,697,675],{},[162,699,701],{"class":164,"line":700},30,[162,702,273],{},[162,704,706],{"class":164,"line":705},31,[162,707,178],{"emptyLinePlaceholder":85},[162,709,711],{"class":164,"line":710},32,[162,712,285],{},[162,714,716],{"class":164,"line":715},33,[162,717,718],{},"    return len;\n",[162,720,722],{"class":164,"line":721},34,[162,723,285],{},[162,725,727],{"class":164,"line":726},35,[162,728,291],{},[109,730,732],{"id":731},"assignments","Assignments",[18,734,735],{},"I finished the assignment from the Machine Learning class, where i had to demonstrate how to make a symbolic-numeric attribute conversion with python. To be more specific, the one that was missing is the symbolic-numeric attribute using pseudo-attributes, so i made a python dictionary with an unique data combination for each author, and then i mapped these objects to the pandas data frame.",[468,737,470],{},{"title":73,"searchDepth":74,"depth":74,"links":739},[740],{"id":103,"depth":74,"text":104,"children":741},[742,743],{"id":111,"depth":175,"text":112},{"id":731,"depth":175,"text":732},"2025-01-16","Solving LeetCode's Remove Duplicates from Sorted Array II and finishing a Machine Learning assignment with pandas.",{},"\u002Fblog\u002Fcode-log-day-10",{"title":488,"description":745},"blog\u002FCode Log - Day 10",[93,94,111],"jB6K_yCHuiMVVLjBFZ_rEhUIrp5USMGOZgc112lasFQ",{"id":753,"title":754,"author":8,"body":755,"date":765,"description":766,"draft":80,"extension":81,"image":82,"language":83,"meta":767,"navigation":85,"part":223,"path":768,"readingTime":88,"seo":769,"series":90,"stem":770,"tags":771,"__hash__":772},"blog\u002Fblog\u002FCode Log - Day 11.md","Code Log - Day 11",{"type":10,"value":756,"toc":762},[757,759],[13,758,104],{"id":103},[18,760,761],{},"Today i only studied about machine learning.",{"title":73,"searchDepth":74,"depth":74,"links":763},[764],{"id":103,"depth":74,"text":104},"2025-01-17","A short day of only studying machine learning.",{},"\u002Fblog\u002Fcode-log-day-11",{"title":754,"description":766},"blog\u002FCode Log - Day 11",[93,94],"qkjsU_tIiqpHY-R6hnxJIrn8gyK4GwljH1tbofEO2MI",{"id":774,"title":775,"author":8,"body":776,"date":888,"description":889,"draft":80,"extension":81,"image":82,"language":83,"meta":890,"navigation":85,"part":229,"path":891,"readingTime":88,"seo":892,"series":90,"stem":893,"tags":894,"__hash__":895},"blog\u002Fblog\u002FCode Log - Day 12.md","Code Log - Day 12",{"type":10,"value":777,"toc":883},[778,780,783,785,792,881],[13,779,104],{"id":103},[18,781,782],{},"Today i worked on a side project.",[109,784,424],{"id":423},[18,786,787,788,791],{},"On the ",[35,789,47],{"href":45,"rel":790},[39]," project, i needed to check if the id of the user trying to call some product-related operation was the same as the user id referenced by the product. Since i'm using Spring Security, in every controller route handler method, i have access to an object of type \"Authentication\" as a parameter, in which i can retrieve the current logged user's id, and pass it to the service layer method, so it can perform the verification.",[154,793,795],{"className":156,"code":794,"language":158,"meta":73,"style":73},"@RestController\n@RequestMapping(\"\u002Fapi\u002Fproducts\")\npublic class ProductsController {\n\n    @Autowired\n    final private ProductsService productsService;\n\n    public ProductsController(ProductsService productsService){\n        this.productsService = productsService;\n    }\n\n    @GetMapping(\"{code}\")\n    @ResponseStatus(HttpStatus.OK)\n    public ProductEntity getProductsByCode(@PathVariable(\"code\") String code, Authentication currentUser) throws ProductNotFoundException{\n        UserEntity currentUserPrincipal = (UserEntity) currentUser.getPrincipal();\n\n        return productsService.getByCode(code,currentUserPrincipal.getUser_uuid());\n    }\n\n",[123,796,797,802,807,812,816,821,826,830,835,840,844,848,853,858,863,868,872,877],{"__ignoreMap":73},[162,798,799],{"class":164,"line":88},[162,800,801],{},"@RestController\n",[162,803,804],{"class":164,"line":74},[162,805,806],{},"@RequestMapping(\"\u002Fapi\u002Fproducts\")\n",[162,808,809],{"class":164,"line":175},[162,810,811],{},"public class ProductsController {\n",[162,813,814],{"class":164,"line":181},[162,815,178],{"emptyLinePlaceholder":85},[162,817,818],{"class":164,"line":187},[162,819,820],{},"    @Autowired\n",[162,822,823],{"class":164,"line":193},[162,824,825],{},"    final private ProductsService productsService;\n",[162,827,828],{"class":164,"line":199},[162,829,178],{"emptyLinePlaceholder":85},[162,831,832],{"class":164,"line":205},[162,833,834],{},"    public ProductsController(ProductsService productsService){\n",[162,836,837],{"class":164,"line":211},[162,838,839],{},"        this.productsService = productsService;\n",[162,841,842],{"class":164,"line":217},[162,843,285],{},[162,845,846],{"class":164,"line":223},[162,847,178],{"emptyLinePlaceholder":85},[162,849,850],{"class":164,"line":229},[162,851,852],{},"    @GetMapping(\"{code}\")\n",[162,854,855],{"class":164,"line":235},[162,856,857],{},"    @ResponseStatus(HttpStatus.OK)\n",[162,859,860],{"class":164,"line":241},[162,861,862],{},"    public ProductEntity getProductsByCode(@PathVariable(\"code\") String code, Authentication currentUser) throws ProductNotFoundException{\n",[162,864,865],{"class":164,"line":247},[162,866,867],{},"        UserEntity currentUserPrincipal = (UserEntity) currentUser.getPrincipal();\n",[162,869,870],{"class":164,"line":253},[162,871,178],{"emptyLinePlaceholder":85},[162,873,874],{"class":164,"line":259},[162,875,876],{},"        return productsService.getByCode(code,currentUserPrincipal.getUser_uuid());\n",[162,878,879],{"class":164,"line":264},[162,880,285],{},[468,882,470],{},{"title":73,"searchDepth":74,"depth":74,"links":884},[885],{"id":103,"depth":74,"text":104,"children":886},[887],{"id":423,"depth":175,"text":424},"2025-01-19","Using Spring Security's Authentication object to check product ownership before running product operations on Ixtore.",{},"\u002Fblog\u002Fcode-log-day-12",{"title":775,"description":889},"blog\u002FCode Log - Day 12",[93,94,158],"bwRUUn0hrra-aWA80DTn5663SJctK8NIRpxGmjUBgCs",{"id":897,"title":898,"author":8,"body":899,"date":916,"description":917,"draft":80,"extension":81,"image":82,"language":83,"meta":918,"navigation":85,"part":235,"path":919,"readingTime":88,"seo":920,"series":90,"stem":921,"tags":922,"__hash__":925},"blog\u002Fblog\u002FCode Log - Day 13.md","Code Log - Day 13",{"type":10,"value":900,"toc":911},[901,903,906,908],[13,902,104],{"id":103},[18,904,905],{},"Today i worked on an assignment from my university.",[109,907,732],{"id":731},[18,909,910],{},"The assignment is from the Distributed System class and it requires to build a chat app using MQTTv5. I started it by configuring the environment, which included installing a MQTT broker and choosing a client, so i installed the Eclipse Mosquitto via docker and created a client using Eclipse Paho with Java. After this, i only did some testing.",{"title":73,"searchDepth":74,"depth":74,"links":912},[913],{"id":103,"depth":74,"text":104,"children":914},[915],{"id":731,"depth":175,"text":732},"2025-01-21","Setting up an MQTTv5 chat app for a Distributed Systems assignment with Eclipse Mosquitto on Docker and the Paho client.",{},"\u002Fblog\u002Fcode-log-day-13",{"title":898,"description":917},"blog\u002FCode Log - Day 13",[93,94,111,158,923,924],"mqtt","docker","8-St0yEwOOG0GbjijICzvkDAiPG9euSMImsT38pw0ag",{"id":927,"title":928,"author":8,"body":929,"date":1111,"description":1112,"draft":80,"extension":81,"image":82,"language":83,"meta":1113,"navigation":85,"part":241,"path":1114,"readingTime":74,"seo":1115,"series":90,"stem":1116,"tags":1117,"__hash__":1118},"blog\u002Fblog\u002FCode Log - Day 14.md","Code Log - Day 14",{"type":10,"value":930,"toc":1105},[931,933,940,942,951,968,998,1096,1098,1100,1103],[13,932,104],{"id":103},[18,934,935,936,939],{},"Today i finished a LeetCode problem from the ",[35,937,500],{"href":498,"rel":938},[39]," list and an assignment from my university.",[109,941,112],{"id":111},[18,943,944,945,947,948,950],{},"The LeetCode exercise i chose was: Rotate Array.\nIt requires a function that receive as input an integer array and their ",[123,946,129],{}," number of rotations to the right  rotate the array to the right by ",[123,949,129],{}," steps :",[117,952,953],{},[18,954,511,955,957,958,960,961,963,964,967],{},[123,956,125],{},", rotate the array to the right by ",[123,959,129],{}," steps, where ",[123,962,129],{}," is non-negative. Could you do it in-place with ",[123,965,966],{},"O(1)"," extra space?",[18,969,970,971,973,974,976,977,979,980,984,985,987,988,991,992,994,995,997],{},"My approach was to subtract k from the array length and use the result as the number of digits in the end of the array that would be swapped with the ",[123,972,129],{}," first ones, and, then, i would \"sort\" the ones in the beginning that now are at the end of the array. However, this solution didn't work for some test cases, due to the subtraction of ",[123,975,129],{}," from the array length (when ",[123,978,129],{}," > length). An alternative, that works well and can be found ",[35,981,302],{"href":982,"rel":983},"https:\u002F\u002Fleetcode.com\u002Fproblems\u002Frotate-array\u002F?envType=study-plan-v2&envId=top-interview-150",[39],", rotates de array by reversing all item and using a new ",[123,986,129],{}," value given by ",[123,989,990],{},"k % nums.length"," as a index to reverse the values before the new ",[123,993,129],{}," and then then values after the new ",[123,996,129],{},":",[154,999,1001],{"className":156,"code":1000,"language":158,"meta":73,"style":73},"class Solution {\n    public void rotate(int[] nums, int k) {\n        \u002F\u002F ex.: nums = [1,2,3,4,5,6,7], k = 11\n        k %= nums.length; \u002F\u002F k = 11 % 7 = 4\n\n        reverse(nums, 0, nums.length - 1); \u002F\u002F [1,2,3,4,5,6,7] -> [7,6,5,4,3,2,1]\n        reverse(nums, 0, k - 1); \u002F\u002F [7,6,5,4,3,2,1] -> [4,5,6,7,3,2,1]\n        reverse(nums, k, nums.length - 1); \u002F\u002F [4,5,6,7,3,2,1] -> [4,5,6,7,1,2,3]\n    }\n\n    private void reverse(int[] nums, int left, int right) {\n        while (left \u003C right) {\n            int temp = nums[left];\n            nums[left] = nums[right];\n            nums[right] = temp;\n            left++;\n            right--;\n        }\n    }\n}\n",[123,1002,1003,1007,1012,1017,1022,1026,1031,1036,1041,1045,1049,1054,1059,1064,1069,1074,1079,1084,1088,1092],{"__ignoreMap":73},[162,1004,1005],{"class":164,"line":88},[162,1006,167],{},[162,1008,1009],{"class":164,"line":74},[162,1010,1011],{},"    public void rotate(int[] nums, int k) {\n",[162,1013,1014],{"class":164,"line":175},[162,1015,1016],{},"        \u002F\u002F ex.: nums = [1,2,3,4,5,6,7], k = 11\n",[162,1018,1019],{"class":164,"line":181},[162,1020,1021],{},"        k %= nums.length; \u002F\u002F k = 11 % 7 = 4\n",[162,1023,1024],{"class":164,"line":187},[162,1025,178],{"emptyLinePlaceholder":85},[162,1027,1028],{"class":164,"line":193},[162,1029,1030],{},"        reverse(nums, 0, nums.length - 1); \u002F\u002F [1,2,3,4,5,6,7] -> [7,6,5,4,3,2,1]\n",[162,1032,1033],{"class":164,"line":199},[162,1034,1035],{},"        reverse(nums, 0, k - 1); \u002F\u002F [7,6,5,4,3,2,1] -> [4,5,6,7,3,2,1]\n",[162,1037,1038],{"class":164,"line":205},[162,1039,1040],{},"        reverse(nums, k, nums.length - 1); \u002F\u002F [4,5,6,7,3,2,1] -> [4,5,6,7,1,2,3]\n",[162,1042,1043],{"class":164,"line":211},[162,1044,285],{},[162,1046,1047],{"class":164,"line":217},[162,1048,178],{"emptyLinePlaceholder":85},[162,1050,1051],{"class":164,"line":223},[162,1052,1053],{},"    private void reverse(int[] nums, int left, int right) {\n",[162,1055,1056],{"class":164,"line":229},[162,1057,1058],{},"        while (left \u003C right) {\n",[162,1060,1061],{"class":164,"line":235},[162,1062,1063],{},"            int temp = nums[left];\n",[162,1065,1066],{"class":164,"line":241},[162,1067,1068],{},"            nums[left] = nums[right];\n",[162,1070,1071],{"class":164,"line":247},[162,1072,1073],{},"            nums[right] = temp;\n",[162,1075,1076],{"class":164,"line":253},[162,1077,1078],{},"            left++;\n",[162,1080,1081],{"class":164,"line":259},[162,1082,1083],{},"            right--;\n",[162,1085,1086],{"class":164,"line":264},[162,1087,273],{},[162,1089,1090],{"class":164,"line":270},[162,1091,285],{},[162,1093,1094],{"class":164,"line":276},[162,1095,291],{},[419,1097],{},[109,1099,732],{"id":731},[18,1101,1102],{},"The assignment was from the Distributed System class and it required to build a chat app using MQTTv5. It basically needed to send messages to an specified \"topic\" or subscribe to one. For this, the Eclipse Paho provides a publish and subscribe methods, so most part of the work was on the input string parsing.",[468,1104,470],{},{"title":73,"searchDepth":74,"depth":74,"links":1106},[1107],{"id":103,"depth":74,"text":104,"children":1108},[1109,1110],{"id":111,"depth":175,"text":112},{"id":731,"depth":175,"text":732},"2025-01-22","Solving LeetCode's Rotate Array and finishing the MQTTv5 chat app assignment with Eclipse Paho.",{},"\u002Fblog\u002Fcode-log-day-14",{"title":928,"description":1112},"blog\u002FCode Log - Day 14",[93,94,111,158,923,924],"uAJuQsovNK58MJmWqd6dFLM42cxpEgNZ3-Kj1CeJv8w",{"id":1120,"title":1121,"author":8,"body":1122,"date":1394,"description":1395,"draft":80,"extension":81,"image":82,"language":83,"meta":1396,"navigation":85,"part":74,"path":1397,"readingTime":74,"seo":1398,"series":90,"stem":1399,"tags":1400,"__hash__":1401},"blog\u002Fblog\u002FCode Log - Day 2.md","Code Log - Day 2",{"type":10,"value":1123,"toc":1389},[1124,1126,1129,1131,1134,1142,1145,1263,1266,1318,1325,1387],[13,1125,104],{"id":103},[18,1127,1128],{},"Today i decided to solve a LeetCode exercise.",[109,1130,112],{"id":111},[18,1132,1133],{},"The LeetCode exercise i chose today was: Longest Common Prefix.\nIt requires a function that receive as input an array of strings to return the longest common prefix between them:",[117,1135,1136],{},[18,1137,1138,1139,143],{},"Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string ",[123,1140,1141],{},"\"\"",[18,1143,1144],{},"My first approach to achieve this was to start a empty prefix string; sort the array by using the length of the strings; make a nested loop with the more external one being used to get the chars of the first string (the smallest one) of the array and the internal one to verify if that char exists in every other string in the array; add the char to the prefix string. However, it was way to slow (3 ms to finish).",[154,1146,1148],{"className":156,"code":1147,"language":158,"meta":73,"style":73},"class Solution {\n    public String longestCommonPrefix(String[] strs) {\n\n        String prefix = \"\";\n\n        if(strs.length == 1 ) return strs[0];\n\n        boolean isIn = true;\n\n        Arrays.sort(strs, Comparator.comparingInt(String::length));\n        for(int i=0; i \u003C strs[0].length() && isIn == true; i++){\n            for(int j=1; j \u003C strs.length; j++){\n\n                if(strs[0].charAt(i) != strs[j].charAt(i)){\n                    isIn = false;\n                    break;\n                }\n            }\n            if(isIn == true){\n                prefix = prefix.concat(String.valueOf(strs[0].charAt(i)));\n            }\n        }\n        return prefix;\n    }\n}\n",[123,1149,1150,1154,1159,1163,1168,1172,1177,1181,1186,1190,1195,1200,1205,1209,1214,1219,1224,1228,1232,1237,1242,1246,1250,1255,1259],{"__ignoreMap":73},[162,1151,1152],{"class":164,"line":88},[162,1153,167],{},[162,1155,1156],{"class":164,"line":74},[162,1157,1158],{},"    public String longestCommonPrefix(String[] strs) {\n",[162,1160,1161],{"class":164,"line":175},[162,1162,178],{"emptyLinePlaceholder":85},[162,1164,1165],{"class":164,"line":181},[162,1166,1167],{},"        String prefix = \"\";\n",[162,1169,1170],{"class":164,"line":187},[162,1171,178],{"emptyLinePlaceholder":85},[162,1173,1174],{"class":164,"line":193},[162,1175,1176],{},"        if(strs.length == 1 ) return strs[0];\n",[162,1178,1179],{"class":164,"line":199},[162,1180,178],{"emptyLinePlaceholder":85},[162,1182,1183],{"class":164,"line":205},[162,1184,1185],{},"        boolean isIn = true;\n",[162,1187,1188],{"class":164,"line":211},[162,1189,178],{"emptyLinePlaceholder":85},[162,1191,1192],{"class":164,"line":217},[162,1193,1194],{},"        Arrays.sort(strs, Comparator.comparingInt(String::length));\n",[162,1196,1197],{"class":164,"line":223},[162,1198,1199],{},"        for(int i=0; i \u003C strs[0].length() && isIn == true; i++){\n",[162,1201,1202],{"class":164,"line":229},[162,1203,1204],{},"            for(int j=1; j \u003C strs.length; j++){\n",[162,1206,1207],{"class":164,"line":235},[162,1208,178],{"emptyLinePlaceholder":85},[162,1210,1211],{"class":164,"line":241},[162,1212,1213],{},"                if(strs[0].charAt(i) != strs[j].charAt(i)){\n",[162,1215,1216],{"class":164,"line":247},[162,1217,1218],{},"                    isIn = false;\n",[162,1220,1221],{"class":164,"line":253},[162,1222,1223],{},"                    break;\n",[162,1225,1226],{"class":164,"line":259},[162,1227,226],{},[162,1229,1230],{"class":164,"line":264},[162,1231,267],{},[162,1233,1234],{"class":164,"line":270},[162,1235,1236],{},"            if(isIn == true){\n",[162,1238,1239],{"class":164,"line":276},[162,1240,1241],{},"                prefix = prefix.concat(String.valueOf(strs[0].charAt(i)));\n",[162,1243,1244],{"class":164,"line":282},[162,1245,267],{},[162,1247,1248],{"class":164,"line":288},[162,1249,273],{},[162,1251,1252],{"class":164,"line":410},[162,1253,1254],{},"        return prefix;\n",[162,1256,1257],{"class":164,"line":415},[162,1258,285],{},[162,1260,1261],{"class":164,"line":672},[162,1262,291],{},[18,1264,1265],{},"So i removed the array sorting and added a check to the if statement inside the more internal nested loop, but it was still taking 2 ms to finish.",[154,1267,1269],{"className":156,"code":1268,"language":158,"meta":73,"style":73},"\u002F\u002F ...\n\u002F\u002F internal loop\nfor(int j=1; j \u003C strs.length; j++){\n    \u002F\u002F changes here:\n    if(i >= strs[j].length() || (i \u003C strs[j].length() && strs[0].charAt(i) != strs[j].charAt(i))){\n        isIn = false;\n        break;\n    }\n}\n\u002F\u002F ...\n",[123,1270,1271,1276,1281,1286,1291,1296,1301,1306,1310,1314],{"__ignoreMap":73},[162,1272,1273],{"class":164,"line":88},[162,1274,1275],{},"\u002F\u002F ...\n",[162,1277,1278],{"class":164,"line":74},[162,1279,1280],{},"\u002F\u002F internal loop\n",[162,1282,1283],{"class":164,"line":175},[162,1284,1285],{},"for(int j=1; j \u003C strs.length; j++){\n",[162,1287,1288],{"class":164,"line":181},[162,1289,1290],{},"    \u002F\u002F changes here:\n",[162,1292,1293],{"class":164,"line":187},[162,1294,1295],{},"    if(i >= strs[j].length() || (i \u003C strs[j].length() && strs[0].charAt(i) != strs[j].charAt(i))){\n",[162,1297,1298],{"class":164,"line":193},[162,1299,1300],{},"        isIn = false;\n",[162,1302,1303],{"class":164,"line":199},[162,1304,1305],{},"        break;\n",[162,1307,1308],{"class":164,"line":205},[162,1309,285],{},[162,1311,1312],{"class":164,"line":211},[162,1313,291],{},[162,1315,1316],{"class":164,"line":217},[162,1317,1275],{},[18,1319,1320,1321,143],{},"Then i found an alternative, with 0 ms of runtime and fewer lines of code that starts with the first string as the prefix and loops through the rest of the array, verifying if the prefix exists in each string, and, if it doesn't, it pops the last character of the prefix and compares again with the same string until the prefix is in the string or it becomes an empty string. This solution can be found ",[35,1322,302],{"href":1323,"rel":1324},"https:\u002F\u002Fleetcode.com\u002Fproblems\u002Flongest-common-prefix\u002Fsolutions\u002F4182958\u002Fjava-c-python-beats-100-beginner-s-friendly\u002F",[39],[154,1326,1328],{"className":156,"code":1327,"language":158,"meta":73,"style":73},"class Solution {\n    public String longestCommonPrefix(String[] strs) {\n\n        if (strs == null || strs.length == 0) return \"\";\n        String prefix = strs[0];\n\n        for(int i = 1; i \u003C strs.length; i++){\n            while (strs[i].indexOf(prefix) != 0)\n                prefix = prefix.substring(0, prefix.length() - 1);\n        }\n        return prefix;\n    }\n}\n",[123,1329,1330,1334,1338,1342,1347,1352,1356,1361,1366,1371,1375,1379,1383],{"__ignoreMap":73},[162,1331,1332],{"class":164,"line":88},[162,1333,167],{},[162,1335,1336],{"class":164,"line":74},[162,1337,1158],{},[162,1339,1340],{"class":164,"line":175},[162,1341,178],{"emptyLinePlaceholder":85},[162,1343,1344],{"class":164,"line":181},[162,1345,1346],{},"        if (strs == null || strs.length == 0) return \"\";\n",[162,1348,1349],{"class":164,"line":187},[162,1350,1351],{},"        String prefix = strs[0];\n",[162,1353,1354],{"class":164,"line":193},[162,1355,178],{"emptyLinePlaceholder":85},[162,1357,1358],{"class":164,"line":199},[162,1359,1360],{},"        for(int i = 1; i \u003C strs.length; i++){\n",[162,1362,1363],{"class":164,"line":205},[162,1364,1365],{},"            while (strs[i].indexOf(prefix) != 0)\n",[162,1367,1368],{"class":164,"line":211},[162,1369,1370],{},"                prefix = prefix.substring(0, prefix.length() - 1);\n",[162,1372,1373],{"class":164,"line":217},[162,1374,273],{},[162,1376,1377],{"class":164,"line":223},[162,1378,1254],{},[162,1380,1381],{"class":164,"line":229},[162,1382,285],{},[162,1384,1385],{"class":164,"line":235},[162,1386,291],{},[468,1388,470],{},{"title":73,"searchDepth":74,"depth":74,"links":1390},[1391],{"id":103,"depth":74,"text":104,"children":1392},[1393],{"id":111,"depth":175,"text":112},"2025-01-08","Solving LeetCode's Longest Common Prefix in Java, and why sorting by string length made the solution simpler.",{},"\u002Fblog\u002Fcode-log-day-2",{"title":1121,"description":1395},"blog\u002FCode Log - Day 2",[93,94,111],"9_TmbK-t0y3sUKSuhVlhVHeYymgkAOI4Ga7uJMiQOVg",{"id":1403,"title":1404,"author":8,"body":1405,"date":1880,"description":1881,"draft":80,"extension":81,"image":82,"language":83,"meta":1882,"navigation":85,"part":175,"path":1883,"readingTime":74,"seo":1884,"series":90,"stem":1885,"tags":1886,"__hash__":1887},"blog\u002Fblog\u002FCode Log - Day 3.md","Code Log - Day 3",{"type":10,"value":1406,"toc":1874},[1407,1409,1416,1418,1421,1426,1433,1614,1617,1861,1863,1865,1872],[13,1408,104],{"id":103},[18,1410,1411,1412,1415],{},"Today i decided to solve a LeetCode exercise and continue to work ",[123,1413,1414],{},"second_brain"," side project open issues.",[109,1417,112],{"id":111},[18,1419,1420],{},"The LeetCode exercise i chose today was: Roman to Integer.\nIt requires a function that receives a string roman numeral as input to return the conversion of this roman numeral to an integer :",[117,1422,1423],{},[18,1424,1425],{},"Given a roman numeral, convert it to an integer.",[18,1427,1428,1429,1432],{},"To achieve this, i had associate each roman numeral character to an actual integer and then loop through each character of the input string \"retrieving\" the integer, so i could add or subtract of a ",[123,1430,1431],{},"num"," integer variable created to store the converted result. At first, i initialized the roman character-integer link using an java Map, but, just as i was already predicting, it would take too much runtime; and it did(7 ms).",[154,1434,1436],{"className":156,"code":1435,"language":158,"meta":73,"style":73},"class Solution {\n    public int romanToInt(String s) {\n        Map\u003CCharacter,Integer> numMap = Map.of(\n            'I', 1,\n            'V', 5,\n            'X', 10,\n            'L', 50,\n            'C', 100,\n            'D', 500,\n            'M',1000\n        );\n\n        int result = 0;\n\n        for(int i = 0; i\u003C s.length(); i++){\n            int num = numMap.get(s.charAt(i));\n            if(i \u003C s.length()-1){\n                if (num == 1 && \"VX\".indexOf(s.charAt(i+1)) != -1){\n                    result -= num;\n                    continue;\n                }\n\n                else if (num == 10 && \"LC\".indexOf(s.charAt(i+1)) != -1){\n                    result -= num;\n                    continue;\n                }\n                else if (num == 100 && \"DM\".indexOf(s.charAt(i+1)) != -1){\n                    result -= num;\n                    continue;\n                }\n            }\n\n            result += num;\n\n        }\n        return result;\n    }\n}\n",[123,1437,1438,1442,1447,1452,1457,1462,1467,1472,1477,1482,1487,1492,1496,1501,1505,1510,1515,1520,1525,1530,1535,1539,1543,1548,1552,1556,1560,1565,1569,1573,1577,1581,1585,1590,1594,1598,1604,1609],{"__ignoreMap":73},[162,1439,1440],{"class":164,"line":88},[162,1441,167],{},[162,1443,1444],{"class":164,"line":74},[162,1445,1446],{},"    public int romanToInt(String s) {\n",[162,1448,1449],{"class":164,"line":175},[162,1450,1451],{},"        Map\u003CCharacter,Integer> numMap = Map.of(\n",[162,1453,1454],{"class":164,"line":181},[162,1455,1456],{},"            'I', 1,\n",[162,1458,1459],{"class":164,"line":187},[162,1460,1461],{},"            'V', 5,\n",[162,1463,1464],{"class":164,"line":193},[162,1465,1466],{},"            'X', 10,\n",[162,1468,1469],{"class":164,"line":199},[162,1470,1471],{},"            'L', 50,\n",[162,1473,1474],{"class":164,"line":205},[162,1475,1476],{},"            'C', 100,\n",[162,1478,1479],{"class":164,"line":211},[162,1480,1481],{},"            'D', 500,\n",[162,1483,1484],{"class":164,"line":217},[162,1485,1486],{},"            'M',1000\n",[162,1488,1489],{"class":164,"line":223},[162,1490,1491],{},"        );\n",[162,1493,1494],{"class":164,"line":229},[162,1495,178],{"emptyLinePlaceholder":85},[162,1497,1498],{"class":164,"line":235},[162,1499,1500],{},"        int result = 0;\n",[162,1502,1503],{"class":164,"line":241},[162,1504,178],{"emptyLinePlaceholder":85},[162,1506,1507],{"class":164,"line":247},[162,1508,1509],{},"        for(int i = 0; i\u003C s.length(); i++){\n",[162,1511,1512],{"class":164,"line":253},[162,1513,1514],{},"            int num = numMap.get(s.charAt(i));\n",[162,1516,1517],{"class":164,"line":259},[162,1518,1519],{},"            if(i \u003C s.length()-1){\n",[162,1521,1522],{"class":164,"line":264},[162,1523,1524],{},"                if (num == 1 && \"VX\".indexOf(s.charAt(i+1)) != -1){\n",[162,1526,1527],{"class":164,"line":270},[162,1528,1529],{},"                    result -= num;\n",[162,1531,1532],{"class":164,"line":276},[162,1533,1534],{},"                    continue;\n",[162,1536,1537],{"class":164,"line":282},[162,1538,226],{},[162,1540,1541],{"class":164,"line":288},[162,1542,178],{"emptyLinePlaceholder":85},[162,1544,1545],{"class":164,"line":410},[162,1546,1547],{},"                else if (num == 10 && \"LC\".indexOf(s.charAt(i+1)) != -1){\n",[162,1549,1550],{"class":164,"line":415},[162,1551,1529],{},[162,1553,1554],{"class":164,"line":672},[162,1555,1534],{},[162,1557,1558],{"class":164,"line":678},[162,1559,226],{},[162,1561,1562],{"class":164,"line":684},[162,1563,1564],{},"                else if (num == 100 && \"DM\".indexOf(s.charAt(i+1)) != -1){\n",[162,1566,1567],{"class":164,"line":689},[162,1568,1529],{},[162,1570,1571],{"class":164,"line":695},[162,1572,1534],{},[162,1574,1575],{"class":164,"line":700},[162,1576,226],{},[162,1578,1579],{"class":164,"line":705},[162,1580,267],{},[162,1582,1583],{"class":164,"line":710},[162,1584,178],{"emptyLinePlaceholder":85},[162,1586,1587],{"class":164,"line":715},[162,1588,1589],{},"            result += num;\n",[162,1591,1592],{"class":164,"line":721},[162,1593,178],{"emptyLinePlaceholder":85},[162,1595,1596],{"class":164,"line":726},[162,1597,273],{},[162,1599,1601],{"class":164,"line":1600},36,[162,1602,1603],{},"        return result;\n",[162,1605,1607],{"class":164,"line":1606},37,[162,1608,285],{},[162,1610,1612],{"class":164,"line":1611},38,[162,1613,291],{},[18,1615,1616],{},"The alternative was to use a switch statement to link the roman numerals characters to integers, and it worked so well that the runtime dropped to 2 ms.",[154,1618,1620],{"className":156,"code":1619,"language":158,"meta":73,"style":73},"class Solution {\n    public int romanToInt(String s) {\n\n        int result = 0;\n\n        for(int i = 0; i\u003C s.length(); i++){\n            int num = s.charAt(i);\n            switch(num){\n                case 'I':\n                    num = 1;\n                    break;\n                case 'V':\n                    num = 5;\n                    break;\n                case 'X':\n                    num = 10;\n                    break;\n                case 'L':\n                    num = 50;\n                    break;\n                case 'C':\n                    num = 100;\n                    break;\n                case 'D':\n                    num = 500;\n                    break;\n                case 'M':\n                    num =1000;\n                    break;\n                default: num = 0;\n            }\n\n            if(i \u003C s.length()-1){\n                if (num == 1 && \"VX\".indexOf(s.charAt(i+1)) != -1){\n                    result -= num;\n                    continue;\n                }\n\n                else if (num == 10 && \"LC\".indexOf(s.charAt(i+1)) != -1){\n                    result -= num;\n                    continue;\n                }\n                else if (num == 100 && \"DM\".indexOf(s.charAt(i+1)) != -1){\n                    result -= num;\n                    continue;\n                }\n            }\n            result += num;\n        }\n        return result;\n    }\n}\n",[123,1621,1622,1626,1630,1634,1638,1642,1646,1651,1656,1661,1666,1670,1675,1680,1684,1689,1694,1698,1703,1708,1712,1717,1722,1726,1731,1736,1740,1745,1750,1754,1759,1763,1767,1771,1775,1779,1783,1787,1791,1796,1801,1806,1811,1816,1821,1826,1831,1836,1841,1846,1851,1856],{"__ignoreMap":73},[162,1623,1624],{"class":164,"line":88},[162,1625,167],{},[162,1627,1628],{"class":164,"line":74},[162,1629,1446],{},[162,1631,1632],{"class":164,"line":175},[162,1633,178],{"emptyLinePlaceholder":85},[162,1635,1636],{"class":164,"line":181},[162,1637,1500],{},[162,1639,1640],{"class":164,"line":187},[162,1641,178],{"emptyLinePlaceholder":85},[162,1643,1644],{"class":164,"line":193},[162,1645,1509],{},[162,1647,1648],{"class":164,"line":199},[162,1649,1650],{},"            int num = s.charAt(i);\n",[162,1652,1653],{"class":164,"line":205},[162,1654,1655],{},"            switch(num){\n",[162,1657,1658],{"class":164,"line":211},[162,1659,1660],{},"                case 'I':\n",[162,1662,1663],{"class":164,"line":217},[162,1664,1665],{},"                    num = 1;\n",[162,1667,1668],{"class":164,"line":223},[162,1669,1223],{},[162,1671,1672],{"class":164,"line":229},[162,1673,1674],{},"                case 'V':\n",[162,1676,1677],{"class":164,"line":235},[162,1678,1679],{},"                    num = 5;\n",[162,1681,1682],{"class":164,"line":241},[162,1683,1223],{},[162,1685,1686],{"class":164,"line":247},[162,1687,1688],{},"                case 'X':\n",[162,1690,1691],{"class":164,"line":253},[162,1692,1693],{},"                    num = 10;\n",[162,1695,1696],{"class":164,"line":259},[162,1697,1223],{},[162,1699,1700],{"class":164,"line":264},[162,1701,1702],{},"                case 'L':\n",[162,1704,1705],{"class":164,"line":270},[162,1706,1707],{},"                    num = 50;\n",[162,1709,1710],{"class":164,"line":276},[162,1711,1223],{},[162,1713,1714],{"class":164,"line":282},[162,1715,1716],{},"                case 'C':\n",[162,1718,1719],{"class":164,"line":288},[162,1720,1721],{},"                    num = 100;\n",[162,1723,1724],{"class":164,"line":410},[162,1725,1223],{},[162,1727,1728],{"class":164,"line":415},[162,1729,1730],{},"                case 'D':\n",[162,1732,1733],{"class":164,"line":672},[162,1734,1735],{},"                    num = 500;\n",[162,1737,1738],{"class":164,"line":678},[162,1739,1223],{},[162,1741,1742],{"class":164,"line":684},[162,1743,1744],{},"                case 'M':\n",[162,1746,1747],{"class":164,"line":689},[162,1748,1749],{},"                    num =1000;\n",[162,1751,1752],{"class":164,"line":695},[162,1753,1223],{},[162,1755,1756],{"class":164,"line":700},[162,1757,1758],{},"                default: num = 0;\n",[162,1760,1761],{"class":164,"line":705},[162,1762,267],{},[162,1764,1765],{"class":164,"line":710},[162,1766,178],{"emptyLinePlaceholder":85},[162,1768,1769],{"class":164,"line":715},[162,1770,1519],{},[162,1772,1773],{"class":164,"line":721},[162,1774,1524],{},[162,1776,1777],{"class":164,"line":726},[162,1778,1529],{},[162,1780,1781],{"class":164,"line":1600},[162,1782,1534],{},[162,1784,1785],{"class":164,"line":1606},[162,1786,226],{},[162,1788,1789],{"class":164,"line":1611},[162,1790,178],{"emptyLinePlaceholder":85},[162,1792,1794],{"class":164,"line":1793},39,[162,1795,1547],{},[162,1797,1799],{"class":164,"line":1798},40,[162,1800,1529],{},[162,1802,1804],{"class":164,"line":1803},41,[162,1805,1534],{},[162,1807,1809],{"class":164,"line":1808},42,[162,1810,226],{},[162,1812,1814],{"class":164,"line":1813},43,[162,1815,1564],{},[162,1817,1819],{"class":164,"line":1818},44,[162,1820,1529],{},[162,1822,1824],{"class":164,"line":1823},45,[162,1825,1534],{},[162,1827,1829],{"class":164,"line":1828},46,[162,1830,226],{},[162,1832,1834],{"class":164,"line":1833},47,[162,1835,267],{},[162,1837,1839],{"class":164,"line":1838},48,[162,1840,1589],{},[162,1842,1844],{"class":164,"line":1843},49,[162,1845,273],{},[162,1847,1849],{"class":164,"line":1848},50,[162,1850,1603],{},[162,1852,1854],{"class":164,"line":1853},51,[162,1855,285],{},[162,1857,1859],{"class":164,"line":1858},52,[162,1860,291],{},[419,1862],{},[109,1864,424],{"id":423},[18,1866,1867,1868,1871],{},"On my {Second Brain](",[35,1869,37],{"href":37,"rel":1870},[39],") project, i worked on the \"Collections\" page to display the list of existing collections; however, i still need to implement the actual functionality to show the posts of a collection.",[468,1873,470],{},{"title":73,"searchDepth":74,"depth":74,"links":1875},[1876],{"id":103,"depth":74,"text":104,"children":1877},[1878,1879],{"id":111,"depth":175,"text":112},{"id":423,"depth":175,"text":424},"2025-01-09","Solving LeetCode's Roman to Integer in Java, and trading a Map for a faster lookup, plus more work on Second Brain.",{},"\u002Fblog\u002Fcode-log-day-3",{"title":1404,"description":1881},"blog\u002FCode Log - Day 3",[93,94,111,484],"0IpISDvkvlxsvSPdqIWE00HvhQS0HT6UVRxGLZMxn7c",{"id":1889,"title":1890,"author":8,"body":1891,"date":2054,"description":2055,"draft":80,"extension":81,"image":82,"language":83,"meta":2056,"navigation":85,"part":181,"path":2057,"readingTime":88,"seo":2058,"series":90,"stem":2059,"tags":2060,"__hash__":2061},"blog\u002Fblog\u002FCode Log - Day 4.md","Code Log - Day 4",{"type":10,"value":1892,"toc":2049},[1893,1895,1898,1900,1903,1916,1919,2047],[13,1894,104],{"id":103},[18,1896,1897],{},"Today i only solved a LeetCode exercise.",[109,1899,112],{"id":111},[18,1901,1902],{},"The LeetCode exercise i chose today was: Remove Duplicates from Sorted List.\nIt requires a function that receives the head of a linked list as input to remove the duplicates and return the list sorted:",[117,1904,1905],{},[18,1906,1907,1908,1911,1912,1915],{},"Given the ",[123,1909,1910],{},"head"," of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list ",[516,1913,1914],{},"sorted"," as well.",[18,1917,1918],{},"To achieve this, i simply went through the linked list verifying if the current node had the same value of the next node, and, if they had the same value, the current node next node would now be the next node of the next node. Since i'm using java, i didn't need to free the memory occupied by the removed node because the garbage collector takes care of it.",[154,1920,1922],{"className":156,"code":1921,"language":158,"meta":73,"style":73},"\u002F**\n * Definition for singly-linked list.\n * public class ListNode {\n *     int val;\n *     ListNode next;\n *     ListNode() {}\n *     ListNode(int val) { this.val = val; }\n *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }\n * }\n *\u002F\nclass Solution {\n    public ListNode deleteDuplicates(ListNode head) {\n        if (head == null) return head;\n\n        ListNode aux = head;\n        while(head.next != null){\n            if(head.val == head.next.val){\n                head.next = head.next.next;\n            } else {\n                head = head.next;\n            }\n        }\n\n        return aux;\n    }\n}\n",[123,1923,1924,1929,1934,1939,1944,1949,1954,1959,1964,1969,1974,1978,1983,1988,1992,1997,2002,2007,2012,2017,2022,2026,2030,2034,2039,2043],{"__ignoreMap":73},[162,1925,1926],{"class":164,"line":88},[162,1927,1928],{},"\u002F**\n",[162,1930,1931],{"class":164,"line":74},[162,1932,1933],{}," * Definition for singly-linked list.\n",[162,1935,1936],{"class":164,"line":175},[162,1937,1938],{}," * public class ListNode {\n",[162,1940,1941],{"class":164,"line":181},[162,1942,1943],{}," *     int val;\n",[162,1945,1946],{"class":164,"line":187},[162,1947,1948],{}," *     ListNode next;\n",[162,1950,1951],{"class":164,"line":193},[162,1952,1953],{}," *     ListNode() {}\n",[162,1955,1956],{"class":164,"line":199},[162,1957,1958],{}," *     ListNode(int val) { this.val = val; }\n",[162,1960,1961],{"class":164,"line":205},[162,1962,1963],{}," *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }\n",[162,1965,1966],{"class":164,"line":211},[162,1967,1968],{}," * }\n",[162,1970,1971],{"class":164,"line":217},[162,1972,1973],{}," *\u002F\n",[162,1975,1976],{"class":164,"line":223},[162,1977,167],{},[162,1979,1980],{"class":164,"line":229},[162,1981,1982],{},"    public ListNode deleteDuplicates(ListNode head) {\n",[162,1984,1985],{"class":164,"line":235},[162,1986,1987],{},"        if (head == null) return head;\n",[162,1989,1990],{"class":164,"line":241},[162,1991,178],{"emptyLinePlaceholder":85},[162,1993,1994],{"class":164,"line":247},[162,1995,1996],{},"        ListNode aux = head;\n",[162,1998,1999],{"class":164,"line":253},[162,2000,2001],{},"        while(head.next != null){\n",[162,2003,2004],{"class":164,"line":259},[162,2005,2006],{},"            if(head.val == head.next.val){\n",[162,2008,2009],{"class":164,"line":264},[162,2010,2011],{},"                head.next = head.next.next;\n",[162,2013,2014],{"class":164,"line":270},[162,2015,2016],{},"            } else {\n",[162,2018,2019],{"class":164,"line":276},[162,2020,2021],{},"                head = head.next;\n",[162,2023,2024],{"class":164,"line":282},[162,2025,267],{},[162,2027,2028],{"class":164,"line":288},[162,2029,273],{},[162,2031,2032],{"class":164,"line":410},[162,2033,178],{"emptyLinePlaceholder":85},[162,2035,2036],{"class":164,"line":415},[162,2037,2038],{},"        return aux;\n",[162,2040,2041],{"class":164,"line":672},[162,2042,285],{},[162,2044,2045],{"class":164,"line":678},[162,2046,291],{},[468,2048,470],{},{"title":73,"searchDepth":74,"depth":74,"links":2050},[2051],{"id":103,"depth":74,"text":104,"children":2052},[2053],{"id":111,"depth":175,"text":112},"2025-01-10","Solving LeetCode's Remove Duplicates from Sorted List in Java.",{},"\u002Fblog\u002Fcode-log-day-4",{"title":1890,"description":2055},"blog\u002FCode Log - Day 4",[93,94,111],"7jvSioWgrTSG0FcrJHrsIHTwWUwkABOPLiAwSUmZSNY",{"id":2063,"title":2064,"author":8,"body":2065,"date":2085,"description":2086,"draft":80,"extension":81,"image":82,"language":83,"meta":2087,"navigation":85,"part":187,"path":2088,"readingTime":88,"seo":2089,"series":90,"stem":2090,"tags":2091,"__hash__":2092},"blog\u002Fblog\u002FCode Log - Day 5.md","Code Log - Day 5",{"type":10,"value":2066,"toc":2080},[2067,2069,2072,2074],[13,2068,104],{"id":103},[18,2070,2071],{},"Today i only worked on a side project open issues.",[109,2073,424],{"id":423},[18,2075,1867,2076,2079],{},[35,2077,37],{"href":37,"rel":2078},[39],") project, i kept working on the \"Collections\" page but implementing the functionality to show the posts of a collection. The way i found to accomplish this, was to pass the name of the collection as a query parameter, so that i could query the posts that belongs to it.",{"title":73,"searchDepth":74,"depth":74,"links":2081},[2082],{"id":103,"depth":74,"text":104,"children":2083},[2084],{"id":423,"depth":175,"text":424},"2025-01-11","Implementing the collection posts listing on my Second Brain project by passing the collection name as a query parameter.",{},"\u002Fblog\u002Fcode-log-day-5",{"title":2064,"description":2086},"blog\u002FCode Log - Day 5",[93,94,484],"-TY0sZK-ao6sDTQQ9duckixkEyjQgCq10E_8h-Lp6KY",{"id":2094,"title":2095,"author":8,"body":2096,"date":2119,"description":2120,"draft":80,"extension":81,"image":82,"language":83,"meta":2121,"navigation":85,"part":193,"path":2122,"readingTime":88,"seo":2123,"series":90,"stem":2124,"tags":2125,"__hash__":2126},"blog\u002Fblog\u002FCode Log - Day 6.md","Code Log - Day 6",{"type":10,"value":2097,"toc":2114},[2098,2100,2103,2105],[13,2099,104],{"id":103},[18,2101,2102],{},"Today i only tested a game development library for a side project.",[109,2104,424],{"id":423},[18,2106,2107,2108,2113],{},"One of my side projects is an Atari 2600 game made with assembly. I've been thinking about the possibility of remaking it for modern platforms (desktop\u002Fmobile devices), so i tested the ",[35,2109,2112],{"href":2110,"rel":2111},"https:\u002F\u002Fgithub.com\u002Fraysan5\u002Fraylib",[39],"raylib"," library as a possibly option, since it's quite easy to use and it allows C and C++ code.",{"title":73,"searchDepth":74,"depth":74,"links":2115},[2116],{"id":103,"depth":74,"text":104,"children":2117},[2118],{"id":423,"depth":175,"text":424},"2025-01-12","Testing raylib as a way to remake an Atari 2600 assembly game for desktop and mobile.",{},"\u002Fblog\u002Fcode-log-day-6",{"title":2095,"description":2120},"blog\u002FCode Log - Day 6",[93,94],"CSMGdZhdYhPyBnURwlmTUBJ010NtVolGQn77XqqAH8s",{"id":2128,"title":2129,"author":8,"body":2130,"date":2150,"description":2151,"draft":80,"extension":81,"image":82,"language":83,"meta":2152,"navigation":85,"part":199,"path":2153,"readingTime":88,"seo":2154,"series":90,"stem":2155,"tags":2156,"__hash__":2157},"blog\u002Fblog\u002FCode Log - Day 7.md","Code Log - Day 7",{"type":10,"value":2131,"toc":2145},[2132,2134,2137,2139,2142],[13,2133,104],{"id":103},[18,2135,2136],{},"Today i worked on some assignments from my university.",[109,2138,732],{"id":731},[18,2140,2141],{},"The first assignment was from the Machine Learning class, where i had to demonstrate how to make a symbolic-numeric attribute conversion with python. So, for this, i used a books dataset from kaggle, and pandas and numpy to help me to clean\u002Ftransform the data.",[18,2143,2144],{},"The second was from the Digital Image Process class involving image filters.",{"title":73,"searchDepth":74,"depth":74,"links":2146},[2147],{"id":103,"depth":74,"text":104,"children":2148},[2149],{"id":731,"depth":175,"text":732},"2025-01-13","Two university assignments on symbolic-to-numeric attribute conversion with pandas and numpy over a Kaggle books dataset.",{},"\u002Fblog\u002Fcode-log-day-7",{"title":2129,"description":2151},"blog\u002FCode Log - Day 7",[93,94],"KQFEAq-4DDu_4YQwC-qryltRmIn2qNRxiRENOaf0B64",{"id":2159,"title":2160,"author":8,"body":2161,"date":2222,"description":2223,"draft":80,"extension":81,"image":82,"language":83,"meta":2224,"navigation":85,"part":205,"path":2225,"readingTime":88,"seo":2226,"series":90,"stem":2227,"tags":2228,"__hash__":2229},"blog\u002Fblog\u002FCode Log - Day 8.md","Code Log - Day 8",{"type":10,"value":2162,"toc":2216},[2163,2165,2168,2170,2173,2201,2203,2205],[13,2164,104],{"id":103},[18,2166,2167],{},"Today i planned the next LeetCode exercises i'll be doing in the futures and started to work on a new unfinished side project.",[109,2169,112],{"id":111},[18,2171,2172],{},"Considering that i was picking random LeetCode exercises to solve, i decided follow a more solid \"path\". So, after some exploration, i selected the following exercises lists:",[29,2174,2175,2180,2187,2194],{},[32,2176,2177],{},[35,2178,500],{"href":498,"rel":2179},[39],[32,2181,2182],{},[35,2183,2186],{"href":2184,"rel":2185},"https:\u002F\u002Fleetcode.com\u002Fstudyplan\u002Fgraph-theory\u002F",[39],"Graph Theory Problems",[32,2188,2189],{},[35,2190,2193],{"href":2191,"rel":2192},"https:\u002F\u002Fleetcode.com\u002Fstudyplan\u002Ftop-sql-50\u002F",[39],"Top 50 SQL Problems",[32,2195,2196],{},[35,2197,2200],{"href":2198,"rel":2199},"https:\u002F\u002Fleetcode.com\u002Fstudyplan\u002F30-days-of-pandas\u002F",[39],"30 Days of Pandas",[419,2202],{},[109,2204,424],{"id":423},[18,2206,2207,2208,2211,2212,2215],{},"Since most of the main features of the ",[35,2209,40],{"href":37,"rel":2210},[39]," project is already done, i went back to work on my ",[35,2213,47],{"href":45,"rel":2214},[39]," side project. As the last lime i worked on it was two months ago, i didn't get too much done because i spent most part of the time reading the code to remember the state of the project, but i did change a repository's method return type, which led to a few broken methods in the service layer (already fixed them).",{"title":73,"searchDepth":74,"depth":74,"links":2217},[2218],{"id":103,"depth":74,"text":104,"children":2219},[2220,2221],{"id":111,"depth":175,"text":112},{"id":423,"depth":175,"text":424},"2025-01-14","Picking structured LeetCode study plans instead of random problems, and getting back into the Ixtore side project.",{},"\u002Fblog\u002Fcode-log-day-8",{"title":2160,"description":2223},"blog\u002FCode Log - Day 8",[93,94,111,158],"r3hJxvs0kCRfqukHPa8QD8vbsadn7HYXCT5oUX3FgCY",{"id":2231,"title":2232,"author":8,"body":2233,"date":2635,"description":2636,"draft":80,"extension":81,"image":82,"language":83,"meta":2637,"navigation":85,"part":211,"path":2638,"readingTime":175,"seo":2639,"series":90,"stem":2640,"tags":2641,"__hash__":2642},"blog\u002Fblog\u002FCode Log - Day 9.md","Code Log - Day 9",{"type":10,"value":2234,"toc":2630},[2235,2237,2243,2245,2260,2302,2323,2515,2525,2628],[13,2236,104],{"id":103},[18,2238,495,2239,2242],{},[35,2240,500],{"href":498,"rel":2241},[39]," list.",[109,2244,112],{"id":111},[18,2246,2247,2248,2251,2252,2255,2256,2259],{},"The LeetCode exercise i chose was: Merge Sorted Array.\nIt requires a function that receive as input two integer arrays and their the number of occupied positions in each of them to merge the arrays into the first array, which has ",[123,2249,2250],{},"m"," items and length of ",[123,2253,2254],{},"m + n",", with ",[123,2257,2258],{},"n"," being the length of the second array :",[117,2261,2262],{},[18,2263,2264,2265,2268,2269,2272,2273,2275,2276,2268,2278,2280,2281,2268,2283,2285,2286,2289,2290,2268,2292,2294,2295,2297,2298,2301],{},"You are given two integer arrays ",[123,2266,2267],{},"nums1"," and ",[123,2270,2271],{},"nums2",", sorted in ",[516,2274,518],{},", and two integers ",[123,2277,2250],{},[123,2279,2258],{},", representing the number of elements in ",[123,2282,2267],{},[123,2284,2271],{}," respectively. ",[516,2287,2288],{},"Merge"," ",[123,2291,2267],{},[123,2293,2271],{}," into a single array sorted in ",[516,2296,518],{},". ...with an algorithm that runs in ",[123,2299,2300],{},"O(m + n)"," time?",[18,2303,2304,2305,2308,2309,2311,2312,2314,2315,2317,2318,2320,2321,997],{},"My first approach was to create a new array ",[123,2306,2307],{},"merge"," and then loop through ",[123,2310,2267],{}," and ",[123,2313,2271],{}," comparing their items to insert into the ",[123,2316,2307],{}," array in a non-decreasing order; after this, the items in the ",[123,2319,2307],{}," would get stored into ",[123,2322,2267],{},[154,2324,2326],{"className":156,"code":2325,"language":158,"meta":73,"style":73},"class Solution {\n    public void merge(int[] nums1, int m, int[] nums2, int n) {\n\n        if ((m == 0 && n == 0) || (m != 0 && n==0) ) return;\n        if (m == 0 && n != 0) {\n            for(int i = 0; i \u003C nums1.length; i++)\n                nums1[i] = nums2[i];\n            return;\n        }\n\n        int[] merged = new int[nums1.length];\n        int j = 0; \u002F\u002F nums1 index\n        int k = 0; \u002F\u002F nums2 index\n\n        for(int i = 0; i \u003C nums1.length; i++){\n           if(j \u003C m && k \u003C n){\n                if(nums1[j] \u003C= nums2[k]){\n                    merged[i] = nums1[j];\n                    j++;\n                    continue;\n                } else {\n                    merged[i] = nums2[k];\n                    k++;\n                    continue;\n                }\n           } else if(j \u003C m && k == n) {\n                merged[i] = nums1[j];\n                j++;\n                continue;\n           } else if(j == m && k \u003C n) {\n                merged[i] = nums2[k];\n                k++;\n                continue;\n           }\n\n        }\n        for(int i = 0; i \u003C nums1.length; i++)\n            nums1[i] = merged[i];\n    }\n}\n",[123,2327,2328,2332,2337,2341,2346,2351,2356,2361,2366,2370,2374,2379,2384,2389,2393,2398,2403,2408,2413,2418,2422,2427,2432,2437,2441,2445,2450,2455,2460,2465,2470,2475,2480,2484,2489,2493,2497,2502,2507,2511],{"__ignoreMap":73},[162,2329,2330],{"class":164,"line":88},[162,2331,167],{},[162,2333,2334],{"class":164,"line":74},[162,2335,2336],{},"    public void merge(int[] nums1, int m, int[] nums2, int n) {\n",[162,2338,2339],{"class":164,"line":175},[162,2340,178],{"emptyLinePlaceholder":85},[162,2342,2343],{"class":164,"line":181},[162,2344,2345],{},"        if ((m == 0 && n == 0) || (m != 0 && n==0) ) return;\n",[162,2347,2348],{"class":164,"line":187},[162,2349,2350],{},"        if (m == 0 && n != 0) {\n",[162,2352,2353],{"class":164,"line":193},[162,2354,2355],{},"            for(int i = 0; i \u003C nums1.length; i++)\n",[162,2357,2358],{"class":164,"line":199},[162,2359,2360],{},"                nums1[i] = nums2[i];\n",[162,2362,2363],{"class":164,"line":205},[162,2364,2365],{},"            return;\n",[162,2367,2368],{"class":164,"line":211},[162,2369,273],{},[162,2371,2372],{"class":164,"line":217},[162,2373,178],{"emptyLinePlaceholder":85},[162,2375,2376],{"class":164,"line":223},[162,2377,2378],{},"        int[] merged = new int[nums1.length];\n",[162,2380,2381],{"class":164,"line":229},[162,2382,2383],{},"        int j = 0; \u002F\u002F nums1 index\n",[162,2385,2386],{"class":164,"line":235},[162,2387,2388],{},"        int k = 0; \u002F\u002F nums2 index\n",[162,2390,2391],{"class":164,"line":241},[162,2392,178],{"emptyLinePlaceholder":85},[162,2394,2395],{"class":164,"line":247},[162,2396,2397],{},"        for(int i = 0; i \u003C nums1.length; i++){\n",[162,2399,2400],{"class":164,"line":253},[162,2401,2402],{},"           if(j \u003C m && k \u003C n){\n",[162,2404,2405],{"class":164,"line":259},[162,2406,2407],{},"                if(nums1[j] \u003C= nums2[k]){\n",[162,2409,2410],{"class":164,"line":264},[162,2411,2412],{},"                    merged[i] = nums1[j];\n",[162,2414,2415],{"class":164,"line":270},[162,2416,2417],{},"                    j++;\n",[162,2419,2420],{"class":164,"line":276},[162,2421,1534],{},[162,2423,2424],{"class":164,"line":282},[162,2425,2426],{},"                } else {\n",[162,2428,2429],{"class":164,"line":288},[162,2430,2431],{},"                    merged[i] = nums2[k];\n",[162,2433,2434],{"class":164,"line":410},[162,2435,2436],{},"                    k++;\n",[162,2438,2439],{"class":164,"line":415},[162,2440,1534],{},[162,2442,2443],{"class":164,"line":672},[162,2444,226],{},[162,2446,2447],{"class":164,"line":678},[162,2448,2449],{},"           } else if(j \u003C m && k == n) {\n",[162,2451,2452],{"class":164,"line":684},[162,2453,2454],{},"                merged[i] = nums1[j];\n",[162,2456,2457],{"class":164,"line":689},[162,2458,2459],{},"                j++;\n",[162,2461,2462],{"class":164,"line":695},[162,2463,2464],{},"                continue;\n",[162,2466,2467],{"class":164,"line":700},[162,2468,2469],{},"           } else if(j == m && k \u003C n) {\n",[162,2471,2472],{"class":164,"line":705},[162,2473,2474],{},"                merged[i] = nums2[k];\n",[162,2476,2477],{"class":164,"line":710},[162,2478,2479],{},"                k++;\n",[162,2481,2482],{"class":164,"line":715},[162,2483,2464],{},[162,2485,2486],{"class":164,"line":721},[162,2487,2488],{},"           }\n",[162,2490,2491],{"class":164,"line":726},[162,2492,178],{"emptyLinePlaceholder":85},[162,2494,2495],{"class":164,"line":1600},[162,2496,273],{},[162,2498,2499],{"class":164,"line":1606},[162,2500,2501],{},"        for(int i = 0; i \u003C nums1.length; i++)\n",[162,2503,2504],{"class":164,"line":1611},[162,2505,2506],{},"            nums1[i] = merged[i];\n",[162,2508,2509],{"class":164,"line":1793},[162,2510,285],{},[162,2512,2513],{"class":164,"line":1798},[162,2514,291],{},[18,2516,2517,2518,2520,2521,143],{},"This works, but there are too many lines of code and there is the need of an extra array. So i found this solution where it takes advantage of the fact that both of the arrays are sorted and the items can easily be inserted at the end of ",[123,2519,2267],{},". It can be found ",[35,2522,302],{"href":2523,"rel":2524},"https:\u002F\u002Fleetcode.com\u002Fproblems\u002Fmerge-sorted-array\u002Fsolutions\u002F3436053\u002Fbeats-100-best-c-java-python-and-javascript-solution-two-pointer-stl\u002F?envType=study-plan-v2&envId=top-interview-150",[39],[154,2526,2528],{"className":156,"code":2527,"language":158,"meta":73,"style":73},"class Solution {\n    public void merge(int[] nums1, int m, int[] nums2, int n) {\n        int i = m - 1;                              \u002F\u002F tracks nums1 items index\n        int j = n - 1;                              \u002F\u002F tracks nums2 items index\n        int k = m + n - 1;                          \u002F\u002F tacks next index to insert at nums1\n\n        while (j >= 0) {                            \u002F\u002F finished looping through nums2?\n                                                    \u002F\u002F nums1 m items still need to get checked\n                                                    \u002F\u002F and item at nums1[i] bigger than nums2[j]\n            if (i >= 0 && nums1[i] > nums2[j]) {\n                                                    \u002F\u002F moves the item at nums1[i] to nums1[k]\n                                                    \u002F\u002F decrement k and i by 1\n                nums1[k--] = nums1[i--];\n            } else {                                \u002F\u002F nums1 0 items need to get checked\n                                                    \u002F\u002F moves the item at nums2[j] to nums1[k]\n                                                    \u002F\u002F decrement k and j by 1\n                nums1[k--] = nums2[j--];\n            }\n        }\n    }\n}\n",[123,2529,2530,2534,2538,2543,2548,2553,2557,2562,2567,2572,2577,2582,2587,2592,2597,2602,2607,2612,2616,2620,2624],{"__ignoreMap":73},[162,2531,2532],{"class":164,"line":88},[162,2533,167],{},[162,2535,2536],{"class":164,"line":74},[162,2537,2336],{},[162,2539,2540],{"class":164,"line":175},[162,2541,2542],{},"        int i = m - 1;                              \u002F\u002F tracks nums1 items index\n",[162,2544,2545],{"class":164,"line":181},[162,2546,2547],{},"        int j = n - 1;                              \u002F\u002F tracks nums2 items index\n",[162,2549,2550],{"class":164,"line":187},[162,2551,2552],{},"        int k = m + n - 1;                          \u002F\u002F tacks next index to insert at nums1\n",[162,2554,2555],{"class":164,"line":193},[162,2556,178],{"emptyLinePlaceholder":85},[162,2558,2559],{"class":164,"line":199},[162,2560,2561],{},"        while (j >= 0) {                            \u002F\u002F finished looping through nums2?\n",[162,2563,2564],{"class":164,"line":205},[162,2565,2566],{},"                                                    \u002F\u002F nums1 m items still need to get checked\n",[162,2568,2569],{"class":164,"line":211},[162,2570,2571],{},"                                                    \u002F\u002F and item at nums1[i] bigger than nums2[j]\n",[162,2573,2574],{"class":164,"line":217},[162,2575,2576],{},"            if (i >= 0 && nums1[i] > nums2[j]) {\n",[162,2578,2579],{"class":164,"line":223},[162,2580,2581],{},"                                                    \u002F\u002F moves the item at nums1[i] to nums1[k]\n",[162,2583,2584],{"class":164,"line":229},[162,2585,2586],{},"                                                    \u002F\u002F decrement k and i by 1\n",[162,2588,2589],{"class":164,"line":235},[162,2590,2591],{},"                nums1[k--] = nums1[i--];\n",[162,2593,2594],{"class":164,"line":241},[162,2595,2596],{},"            } else {                                \u002F\u002F nums1 0 items need to get checked\n",[162,2598,2599],{"class":164,"line":247},[162,2600,2601],{},"                                                    \u002F\u002F moves the item at nums2[j] to nums1[k]\n",[162,2603,2604],{"class":164,"line":253},[162,2605,2606],{},"                                                    \u002F\u002F decrement k and j by 1\n",[162,2608,2609],{"class":164,"line":259},[162,2610,2611],{},"                nums1[k--] = nums2[j--];\n",[162,2613,2614],{"class":164,"line":264},[162,2615,267],{},[162,2617,2618],{"class":164,"line":270},[162,2619,273],{},[162,2621,2622],{"class":164,"line":276},[162,2623,285],{},[162,2625,2626],{"class":164,"line":282},[162,2627,291],{},[468,2629,470],{},{"title":73,"searchDepth":74,"depth":74,"links":2631},[2632],{"id":103,"depth":74,"text":104,"children":2633},[2634],{"id":111,"depth":175,"text":112},"2025-01-15","Solving LeetCode's Merge Sorted Array from the Top Interview 150 list.",{},"\u002Fblog\u002Fcode-log-day-9",{"title":2232,"description":2636},"blog\u002FCode Log - Day 9",[93,94,111],"UWyrDG_YrOifYo9Wpw2Vq5-L9yADQq2YiVMNhzIwsmo",{"id":2644,"title":2645,"author":8,"body":2646,"date":2744,"description":2745,"draft":80,"extension":81,"image":82,"language":83,"meta":2746,"navigation":85,"part":88,"path":2747,"readingTime":74,"seo":2748,"series":2749,"stem":2750,"tags":2751,"__hash__":2755},"blog\u002Fblog\u002FImproving My Go CLI - Ehfolder - 01.md","Improving My Go CLI - Ehfolder - 01",{"type":10,"value":2647,"toc":2737},[2648,2652,2655,2658,2667,2671,2675,2695,2699,2705],[13,2649,2651],{"id":2650},"introduction","Introduction",[18,2653,2654],{},"Have you ever thought about creating a folder containing folders and files for a project, be it an RPG worldbuilding setting or a desktop game, planned it out in a file, and then abandoned it because you were too lazy to create everything manually?",[18,2656,2657],{},"Have you ever created a folder with multiple folders and files following some sort of logic or structure, and then couldn't make sense of it after not touching it for a while?",[18,2659,2660,2661,2666],{},"These are the reasons why I created this simple Go CLI called ",[35,2662,2665],{"href":2663,"rel":2664},"https:\u002F\u002Fgithub.com\u002Fcaioopr\u002Fehfolder",[39],"Ehfolder"," some time ago. However, I only implemented folder and file creation, there are a lot of features still missing that I will try to finish. The next sections contain the missing features and some improvements I intend to implement.",[13,2668,2670],{"id":2669},"planning","Planning",[109,2672,2674],{"id":2673},"missing-features","Missing Features",[29,2676,2677,2683,2689],{},[32,2678,2679,2682],{},[516,2680,2681],{},"File and folder custom metadata",": allow the user to create and manage custom metadata (on the planning file or on existing files\u002Ffolders), like adding a description or tags to a file\u002Ffolder.",[32,2684,2685,2688],{},[516,2686,2687],{},"Folder info",": allow the user to view information about the contents of a folder, including custom properties like how many files\u002Ffolders have the tag \"X\", or what tags exist in there.",[32,2690,2691,2694],{},[516,2692,2693],{},"Advanced search and filters",": allow the user to search and filter based on custom metadata.",[109,2696,2698],{"id":2697},"improvements","Improvements",[18,2700,2701,2704],{},[516,2702,2703],{},"Core package",": since I plan to make a desktop GUI, I want to extract the core functionality into a package to decouple it from the CLI so I can easily reuse it.",[29,2706,2707,2713,2725],{},[32,2708,2709,2712],{},[516,2710,2711],{},"YAML file compatibility",": currently, folder\u002Ffile creation only accepts Markdown and text files, but since many people are used to writing configuration files in YAML, why not add a parser for it?",[32,2714,2715,2718,2719,2724],{},[516,2716,2717],{},"TUI",": maybe a cup of ",[35,2720,2723],{"href":2721,"rel":2722},"https:\u002F\u002Fgithub.com\u002Fcharmbracelet\u002Fbubbletea",[39],"Bubbletea"," to make it look clean.",[32,2726,2727,2730,2731,2736],{},[516,2728,2729],{},"Desktop GUI",": some users aren't used to CLIs, and I want to try out the ",[35,2732,2735],{"href":2733,"rel":2734},"https:\u002F\u002Fgithub.com\u002Fwailsapp\u002Fwails",[39],"Wails"," project, so why not?",{"title":73,"searchDepth":74,"depth":74,"links":2738},[2739,2740],{"id":2650,"depth":74,"text":2651},{"id":2669,"depth":74,"text":2670,"children":2741},[2742,2743],{"id":2673,"depth":175,"text":2674},{"id":2697,"depth":175,"text":2698},"2026-08-20","Planning and implementing new features for my Go file\u002Ffolder manager CLI.",{},"\u002Fblog\u002Fimproving-my-go-cli-ehfolder-01",{"title":2645,"description":2745},"ehfolder","blog\u002FImproving My Go CLI - Ehfolder - 01",[2752,2670,2753,2754,2665],"CLI","Programming","Go","JmB55YIMN3UCOgQp3UJpVk3zGG4D_22lg3YJZhgyCzE",[2757,2767],{"id":2758,"title":2759,"dek":2760,"description":2761,"extension":2762,"meta":2763,"next":82,"status":2764,"stem":2765,"__hash__":2766},"series\u002Fseries\u002Fcode-log.yml","Code Log","Fifteen days of showing up to code, written down.","A daily coding challenge from January 2025 — LeetCode exercises, side-project issues and university assignments, logged one day at a time. Each entry stands alone, but reading them in order shows the habit take shape.","yml",{},"complete","series\u002Fcode-log","yDC0Gi8XWWRCyH1So9GTFjqIiI7IO5InMLPAT23yu-E",{"id":2768,"title":2769,"dek":2770,"description":2771,"extension":2762,"meta":2772,"next":2773,"status":2774,"stem":2775,"__hash__":2776},"series\u002Fseries\u002Fehfolder.yml","Improving Ehfolder","Growing a small Go CLI, one feature at a time.","Planning and building new features for Ehfolder, my Go command-line tool that scaffolds folder and file structures from a plan. Best read in order.",{},"Improving My Go CLI - Ehfolder - 02","ongoing","series\u002Fehfolder","SNBSujKazpDeGssWNHLgnBmOoa4foZp3DAgVmEhPPGg",1792631994827]