<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>C&#43;&#43; on Ito Archives</title>
    <link>https://itoschum.me/tags/c&#43;&#43;/</link>
    <description>Recent content in C&#43;&#43; on Ito Archives</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 04 Sep 2021 17:22:00 -0400</lastBuildDate>
    <atom:link href="https://itoschum.me/tags/c++/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>C&#43;&#43; Implementation of LRU &amp; LFU Cache</title>
      <link>https://itoschum.me/logs/log_07/</link>
      <pubDate>Sat, 04 Sep 2021 17:22:00 -0400</pubDate>
      <guid>https://itoschum.me/logs/log_07/</guid>
      <description>&lt;h2 id=&#34;lru-least-recently-used-cache&#34;&gt;LRU (Least Recently Used) Cache&lt;/h2&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Referring to LeetCode Q146 &lt;a href=&#34;https://leetcode.com/problems/lru-cache/&#34;&gt;https://leetcode.com/problems/lru-cache/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h3 id=&#34;description&#34;&gt;Description&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;LRUCache(int capacity)&lt;/code&gt; Initialize the LRU cache with positive size capacity.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;int get(int key)&lt;/code&gt; Return the value of the key if the key exists, otherwise return -1.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;void put(int key, int value)&lt;/code&gt; Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used&lt;/li&gt;&#xA;&lt;li&gt;The functions &lt;code&gt;get&lt;/code&gt; and &lt;code&gt;put&lt;/code&gt; must each run in &lt;code&gt;O(1)&lt;/code&gt; average time complexity.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;data-structure-used&#34;&gt;Data Structure Used&lt;/h3&gt;&#xA;&lt;p&gt;To satisfy the &lt;code&gt;O(1)&lt;/code&gt; average time complexity for &lt;code&gt;get&lt;/code&gt; and &lt;code&gt;put&lt;/code&gt;,&lt;/p&gt;</description>
    </item>
    <item>
      <title>Visual Studio Code C/C&#43;&#43; Extension Setup on M1 Mac</title>
      <link>https://itoschum.me/logs/log_06/</link>
      <pubDate>Wed, 17 Mar 2021 14:32:00 -0400</pubDate>
      <guid>https://itoschum.me/logs/log_06/</guid>
      <description>&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Visual Studio Code extension &lt;code&gt;ms-vscode.cpptools&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Xcode Command-line Tools / Xcode IDE&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;To install Xcode Command-line Tools: &lt;code&gt;xcode-select --install&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;To install Xcode IDE: &lt;code&gt;mas install Xcode&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;test-environment&#34;&gt;Test Environment&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Visual Studio Code 1.54.3 (Universal)&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Commit: 2b9aebd5354a3629c3aba0a5f5df49f43d6689f8&lt;/li&gt;&#xA;&lt;li&gt;Extension: ms-vscode.cpptools v1.2.2&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;macOS 11.2.3&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-Bash&#34; data-lang=&#34;Bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ uname -v&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Darwin Kernel Version 20.3.0: Thu Jan &lt;span style=&#34;color:#ae81ff&#34;&gt;21&lt;/span&gt; 00:06:51 PST 2021;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;root:xnu-7195.81.3~1/RELEASE_ARM64_T8101&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Xcode 12.4 (12D4e)&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-Bash&#34; data-lang=&#34;Bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ clang --version&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Apple clang version 12.0.0 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;clang-1200.0.32.29&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Target: arm64-apple-darwin20.3.0&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Thread model: posix&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;setup&#34;&gt;Setup&lt;/h2&gt;&#xA;&lt;p&gt;Modify the &lt;code&gt;settings.json&lt;/code&gt; in Visual Studio Code as shown below&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
