{"id":1634,"date":"2024-02-03T13:00:00","date_gmt":"2024-02-03T13:00:00","guid":{"rendered":"https:\/\/favtutor.com\/articles\/?p=1634"},"modified":"2024-02-05T05:19:29","modified_gmt":"2024-02-05T05:19:29","slug":"lfu-cache-problem","status":"publish","type":"post","link":"https:\/\/favtutor.com\/articles\/lfu-cache-problem\/","title":{"rendered":"LFU Cache Problem Solved (C++, Java, Python)"},"content":{"rendered":"\n<p>In data management, efficient caching mechanisms are important in enhancing system performance. One of the cache replacement policies is the Least Frequently Used algorithm. In this article, we will discuss how to solve the LFU cache problem.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What is LFU Cache?<\/strong><\/h2>\n\n\n\n<p><strong>LFU, or Least Frequently Used, is a caching strategy where the system tracks the access frequency of cached elements and discards the element with the lowest number of accesses when the cache reaches its capacity.<\/strong><\/p>\n\n\n\n<p>This strategy prioritizes retaining the elements that have been accessed most often in the past, optimizing cache utilization for scenarios where recently accessed elements are likely to be needed again soon.<\/p>\n\n\n\n<p>Let\u2019s discuss how we can implement LFU Cache.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Using Hashing Approach<\/strong><\/h2>\n\n\n\n<p><strong>The hashing Approach is used to implement LFU Cache in this we will use Three hash-maps to implement LFU Cache.<\/strong><\/p>\n\n\n\n<p>Below are the steps to be followed to solve this Problem:-<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Firstly we will declare three hashmaps \u201cfrequencyList\u201d, \u201ckeyNode\u201d and \u201cfrequency\u201d.<\/li>\n\n\n\n<li>In these hashmaps, we have key-value pairs in the following manner:\n<ul class=\"wp-block-list\">\n<li><strong>frequencyList: <\/strong>the key is an integer and the value will be a list<\/li>\n\n\n\n<li><strong>keyNode<\/strong>: the key is an integer and the value is an iterator containing the iterator for an element of a specific frequency of frequencyList.<\/li>\n\n\n\n<li><strong>frequency<\/strong>: key is an integer value that is a pair of two other integers containing the frequency count and the value of a particular key.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>We will declare Two variables &#8216;minFrequency&#8217; which will hold the minimum frequency from which we need to remove the number and &#8216;currentSize&#8217; which determines the size of the LFU Cache.<\/li>\n<\/ul>\n\n\n\n<p>Here are the 3 functions we need to solve the problem:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>LFUCache(int capacity) <\/strong>Initialize the LFU cache with positive size capacity<strong>.<\/strong><\/li>\n\n\n\n<li><strong>int get(int key)\u00a0<\/strong>\n<ul class=\"wp-block-list\">\n<li>In LFU if the key is new. we need to return -1.<\/li>\n\n\n\n<li>If the key is not new, then we need to erase that key from the frequencyList. Also, increase the frequency count of the current element.\u00a0<\/li>\n\n\n\n<li>Now Insert them into the frequencyList.<\/li>\n\n\n\n<li>If the minFrequency list is 0, then increase minFrequency by 1.<\/li>\n\n\n\n<li>Return the corresponding value for the given key.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>void put(int key, int value)<\/strong>\n<ul class=\"wp-block-list\">\n<li>If the capacity is less than 1, no put() operation will take place.<\/li>\n\n\n\n<li>Now, if the given key is a new one and we are at capacity then we need to remove the least used key.<\/li>\n\n\n\n<li>We will remove the very last element available from the frequencyList of minFrequency index. We also remove that element from frequency hashmap as well.<\/li>\n\n\n\n<li>\u00a0As the item is a new one then, the minFrequency will be set to 1. And we will add them in frequencyList&#8217;s minFrequency index, frequency, and keyNode.<\/li>\n\n\n\n<li>If the key is not new, then we need to add the value to the frequency hashmap.<\/li>\n\n\n\n<li>Then we will call the get() function.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>Let&#8217;s take an example:<\/p>\n\n\n\n<p><strong>Input: <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-text-color has-background has-link-color wp-elements-96213a60a2f61afbd0bed66ca6a70fed\" style=\"background-color:#fedcba\"><code>&#91;\"LFUCache\", \"put\", \"put\", \"get\", \"put\", \"get\", \"get\", \"put\", \"get\", \"get\", \"get\"]\n&#91;&#91;2], &#91;1, 1], &#91;2, 2], &#91;1], &#91;3, 3], &#91;2], &#91;3], &#91;4, 4], &#91;1], &#91;3], &#91;4]]<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-text-color has-background has-link-color wp-elements-a80752cab8d3ea69474c93bd9fbc3a0c\" style=\"background-color:#fedcba\"><code>&#91;null, null, null, 1, null, -1, 3, null, -1, 3, 4]<\/code><\/pre>\n\n\n\n<p><strong>Explanation:<\/strong><\/p>\n\n\n\n<p><strong>cnt(x) =<\/strong> the use counter for key x<\/p>\n\n\n\n<p>cache=[] will show the last used order for tiebreakers (the leftmost element is the most recent)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In this firstly we are declaring LFU of size 2<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh7-us.googleusercontent.com\/yQxzDQ0rPt6wwkPJZqhNP_8N3oL-WvPu_OBA00-Z5zTmfhbiVlJ8HdJyiUujvSpYJ1iNaCX4CYHyUlktjq72fgfiXzJxY8r-3Q5EPfw1wZtBRuQO9TnvFkDMf8AjNtf2NS7FWf38VZqFWUnD4-FGZQc\" alt=\"Declaring LFU of size 2\" style=\"width:213px;height:auto\"\/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>LFUCache.put(1,1) now cache = [1,_] and cnt(1) = 1;<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh7-us.googleusercontent.com\/0MAR-UGyvmkopY7tgLBYKaZhroXUt8kbMo1PCzPyqwNAQgsNcCWadoap0A1eRTgu3gK09TN13dKtGch1oTTZGg7AWS53AA96vXj9t136fxoc3rUM3vLd0GB9ps6eULPziUPb--asENCZt4ah2BK-GvY\" alt=\"Put (1,1) in LFU cache\" style=\"width:223px;height:auto\"\/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>LFUCache.put(2,2) now cache = [2,1] and cnt(1) = 1, cnt(2) = 1<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh7-us.googleusercontent.com\/kRATDmFpRk7U_wt82d0kusEvKw5R0hLhKV_hL6fVjCCDIVASwaY0ZTezOZRZwUkzWcNbCcNftfw-zh1divKxTzZ-hXWhgGrMW3J-esoWI7pbPXTFzjCu78c8j7Z8ELbT9Hr2nFwVqIU1RkKUYdP1Xz8\" alt=\"Put (2,2) in LFU Cache\" style=\"width:235px;height:auto\"\/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>LFUCache.get(1) and 1 is present so we will return 1, cache=[1,2], cnt(2)=1, cnt(1)=2<\/li>\n\n\n\n<li>LFUCache.put(3,3) now 2 is the LFU key because cnt(2)=1 is the smallest, invalidate 2. cache = [3,1] and cnt(3) = 1, cnt(1) = 2<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh7-us.googleusercontent.com\/mUlNca_SajdWrmAG_iccBxevz55nnqqnbEERQh7E0b3eaXVEQeU07rqY3oe49hyzhIlqrTIa4PNhfhyGocspy06aIGPnMXLLsagjL6wFSC3MZXsit5-7dNQjfMp6KxJ5oR0fU4PaNGmuHJ0TjjRCpwY\" alt=\"Put (3,3) in LFU Cache\" style=\"width:239px;height:auto\"\/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>LFUCache.get(2); we will return -1.<\/li>\n\n\n\n<li>LFUCache.get(3); we will return 3. And now cache = [3,1] and cnt(3) = 2, cnt(1) = 2.<\/li>\n\n\n\n<li>LFUCache.put(4,4) now Both 1 and 3 have the same count, but 1 is LRU, invalidate 1. Now cache=[4,3], cnt(4)=1, cnt(3)=2<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh7-us.googleusercontent.com\/nTq6KqD2lWodryTL5WgvCd4LOz_Q2XsRIy5XBzjDFoAmpfBwn0UfWbuBmVYBAY02NS8MLuLHkq_UcDZJPbp2rwWANQakP7IyyH8ApL8m6qhn8ByXoFcbaahGdbKu2jRtTc4YGjRwf7YkqJWN5CUYEU0\" alt=\"Put (4,4) in LFU Cache\" style=\"width:255px;height:auto\"\/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>LFUCache.get(1); we will return -1.<\/li>\n\n\n\n<li>LFUCache.get(3); we will return 3. Now cache=[3,4], cnt(4)=1, cnt(3)=3<\/li>\n\n\n\n<li>LFUCache.get(4); we will return 4. Now cache=[4,3], cnt(4)=2, cnt(3)=3<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>C++ Code<\/strong><\/h3>\n\n\n\n<p>Here is the C++ program to implement LFU Cache problem:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-c++src&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;C++&quot;,&quot;modeName&quot;:&quot;cpp&quot;}\">#include &lt;iostream&gt;\n#include &lt;unordered_map&gt;\n#include &lt;list&gt;\n\nusing namespace std;\n\nclass LFUCache {\npublic:\n    int Capacity, minFrequency = 0, currentSize = 0;\n    unordered_map&lt;int, list&lt;int&gt;&gt; frequencyList; \/\/ Map to store keys based on frequency\n    unordered_map&lt;int, list&lt;int&gt;::iterator&gt; keyNode; \/\/ Map to store iterator pointing to the position of keys in frequencyList\n    unordered_map&lt;int, pair&lt;int, int&gt;&gt; frequency; \/\/ Map to store frequency and value of each key\n\n    LFUCache(int capacity) {\n        Capacity = capacity;\n        minFrequency = 0, currentSize = 0;\n    }\n\n    \/\/ Function to get the value of a key\n    int get(int key) {\n        if (keyNode.find(key) == keyNode.end())\n            return -1; \/\/ Key not found\n\n        int keyFreq = frequency[key].first;\n        frequencyList[keyFreq].erase(keyNode[key]);\n\n        frequency[key].first++;\n        frequencyList[frequency[key].first].push_front(key);\n        keyNode[key] = frequencyList[frequency[key].first].begin();\n\n        if (frequencyList[minFrequency].size() == 0)\n            minFrequency++; \/\/ Update minFrequency if the list is empty\n\n        return frequency[key].second; \/\/ Return the value of the key\n    }\n\n    \/\/ Function to put a key-value pair into the cache\n    void put(int key, int value) {\n        if (Capacity &lt;= 0)\n            return; \/\/ Capacity is zero or negative, do nothing\n\n        if (keyNode.find(key) != keyNode.end()) {\n            \/\/ Key already exists, update its value and frequency\n            frequency[key].second = value;\n            get(key);\n            return;\n        }\n\n        \/\/ New Element\n        if (currentSize == Capacity) {\n            \/\/ Cache is full, evict the least frequently used key\n            int minFreqBack = frequencyList[minFrequency].back();\n            keyNode.erase(minFreqBack);\n            frequency.erase(minFreqBack);\n            frequencyList[minFrequency].pop_back();\n            currentSize--;\n        }\n\n        \/\/ Add the new key to the cache\n        currentSize++;\n        minFrequency = 1;\n        frequencyList[minFrequency].push_front(key);\n        keyNode[key] = frequencyList[minFrequency].begin();\n        frequency[key].first = 1, frequency[key].second = value;\n    }\n};\n\nint main() {\n    \/\/ Example Usage\n    LFUCache lfuCache(2);\n\n    lfuCache.put(1, 1);\n    lfuCache.put(2, 2);\n    cout &lt;&lt; lfuCache.get(1) &lt;&lt; endl; \/\/ Output: 1\n    lfuCache.put(3, 3);\n    cout &lt;&lt; lfuCache.get(2) &lt;&lt; endl; \/\/ Output: -1\n    cout &lt;&lt; lfuCache.get(3) &lt;&lt; endl; \/\/ Output: 3\n    lfuCache.put(4, 4);\n    cout &lt;&lt; lfuCache.get(1) &lt;&lt; endl; \/\/ Output: -1\n    cout &lt;&lt; lfuCache.get(3) &lt;&lt; endl; \/\/ Output: 3\n    cout &lt;&lt; lfuCache.get(4) &lt;&lt; endl; \/\/ Output: 4\n\n    return 0;\n}<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Python Code<\/strong><\/h3>\n\n\n\n<p>Here is the Python solution for this problem:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;Python&quot;,&quot;modeName&quot;:&quot;python&quot;}\">from collections import defaultdict, OrderedDict\n\nclass LFUCache:\n    def __init__(self, capacity):\n        self.capacity = capacity\n        self.min_frequency = 0\n        self.current_size = 0\n        self.frequency_list = defaultdict(OrderedDict)  # Dictionary to store keys based on frequency\n        self.key_node = {}  # Dictionary to store the position of keys in frequency_list\n        self.frequency = {}  # Dictionary to store frequency and value of each key\n\n    def get(self, key):\n        if key not in self.key_node:\n            return -1  # Key not found\n\n        key_freq = self.frequency[key][0]\n        del self.frequency_list[key_freq][key]\n\n        self.frequency[key][0] += 1\n        self.frequency_list[self.frequency[key][0]][key] = None\n        self.key_node[key] = next(iter(self.frequency_list[self.frequency[key][0]]))\n\n        if not self.frequency_list[self.min_frequency]:\n            self.min_frequency += 1  # Update min_frequency if the list is empty\n\n        return self.frequency[key][1]  # Return the value of the key\n\n    def put(self, key, value):\n        if self.capacity &lt;= 0:\n            return  # Capacity is zero or negative, do nothing\n\n        if key in self.key_node:\n            # Key already exists, update its value and frequency\n            self.frequency[key][1] = value\n            self.get(key)\n            return\n\n        # New Element\n        if self.current_size == self.capacity:\n            # Cache is full, evict the least frequently used key\n            min_freq_key = next(iter(self.frequency_list[self.min_frequency]))\n            del self.key_node[min_freq_key]\n            del self.frequency[min_freq_key]\n            del self.frequency_list[self.min_frequency][min_freq_key]\n            self.current_size -= 1\n\n        # Add the new key to the cache\n        self.current_size += 1\n        self.min_frequency = 1\n        self.frequency_list[self.min_frequency][key] = None\n        self.key_node[key] = next(iter(self.frequency_list[self.min_frequency]))\n        self.frequency[key] = [1, value]\n\n# Example Usage\nlfu_cache = LFUCache(2)\nlfu_cache.put(1, 1)\nlfu_cache.put(2, 2)\nprint(lfu_cache.get(1))  # Output: 1\nlfu_cache.put(3, 3)\nprint(lfu_cache.get(2))  # Output: -1\nprint(lfu_cache.get(3))  # Output: 3\nlfu_cache.put(4, 4)\nprint(lfu_cache.get(1))  # Output: -1\nprint(lfu_cache.get(3))  # Output: 3\nprint(lfu_cache.get(4))  # Output: 4<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Java Code<\/strong><\/h3>\n\n\n\n<p>You can do it in Java also:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;Java&quot;,&quot;modeName&quot;:&quot;java&quot;}\">import java.util.*;\n\nclass LFUCache {\n    private int capacity;\n    private int minFrequency;\n    private int currentSize;\n    private Map&lt;Integer, LinkedHashMap&lt;Integer, Void&gt;&gt; frequencyList; \/\/ Map to store keys based on frequency\n    private Map&lt;Integer, Integer&gt; keyNode; \/\/ Map to store the position of keys in frequencyList\n    private Map&lt;Integer, int[]&gt; frequency; \/\/ Map to store frequency and value of each key\n\n    public LFUCache(int capacity) {\n        this.capacity = capacity;\n        this.minFrequency = 0;\n        this.currentSize = 0;\n        this.frequencyList = new HashMap&lt;&gt;();\n        this.keyNode = new HashMap&lt;&gt;();\n        this.frequency = new HashMap&lt;&gt;();\n    }\n\n    public int get(int key) {\n        if (!keyNode.containsKey(key)) {\n            return -1; \/\/ Key not found\n        }\n\n        int keyFreq = frequency.get(key)[0];\n        frequencyList.get(keyFreq).remove(key);\n\n        frequency.get(key)[0]++;\n        frequencyList.computeIfAbsent(frequency.get(key)[0], k -&gt; new LinkedHashMap&lt;&gt;()).put(key, null);\n        keyNode.put(key, frequencyList.get(frequency.get(key)[0]).keySet().iterator().next());\n\n        if (frequencyList.get(minFrequency).isEmpty()) {\n            minFrequency++; \/\/ Update minFrequency if the list is empty\n        }\n\n        return frequency.get(key)[1]; \/\/ Return the value of the key\n    }\n\n    public void put(int key, int value) {\n        if (capacity &lt;= 0) {\n            return; \/\/ Capacity is zero or negative, do nothing\n        }\n\n        if (keyNode.containsKey(key)) {\n            \/\/ Key already exists, update its value and frequency\n            frequency.get(key)[1] = value;\n            get(key);\n            return;\n        }\n\n        \/\/ New Element\n        if (currentSize == capacity) {\n            \/\/ Cache is full, evict the least frequently used key\n            int minFreqKey = frequencyList.get(minFrequency).keySet().iterator().next();\n            keyNode.remove(minFreqKey);\n            frequency.remove(minFreqKey);\n            frequencyList.get(minFrequency).remove(minFreqKey);\n            currentSize--;\n        }\n\n        \/\/ Add the new key to the cache\n        currentSize++;\n        minFrequency = 1;\n        frequencyList.computeIfAbsent(minFrequency, k -&gt; new LinkedHashMap&lt;&gt;()).put(key, null);\n        keyNode.put(key, frequencyList.get(minFrequency).keySet().iterator().next());\n        frequency.put(key, new int[]{1, value});\n    }\n\n    public static void main(String[] args) {\n        \/\/ Example Usage\n        LFUCache lfuCache = new LFUCache(2);\n        lfuCache.put(1, 1);\n        lfuCache.put(2, 2);\n        System.out.println(lfuCache.get(1)); \/\/ Output: 1\n        lfuCache.put(3, 3);\n        System.out.println(lfuCache.get(2)); \/\/ Output: -1\n        System.out.println(lfuCache.get(3)); \/\/ Output: 3\n        lfuCache.put(4, 4);\n        System.out.println(lfuCache.get(1)); \/\/ Output: -1\n        System.out.println(lfuCache.get(3)); \/\/ Output: 3\n        System.out.println(lfuCache.get(4)); \/\/ Output: 4\n    }\n}<\/pre><\/div>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-text-color has-background has-link-color wp-elements-e98eda4041d3b289b93ff26f94bc6d5c\" style=\"background-color:#fedcba\"><code>1\n-1\n3\n-1\n3\n4\n<\/code><\/pre>\n\n\n\n<p>The Time Complexity for this approach is O(1) because accessing and removing elements from the hashmap takes O(1) time complexity. The Space Complexity is O(capacity^2), which is mainly due to the storage of frequency lists using HashMaps. Here capacity is the size of the frequencylist.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>In conclusion, we solved the LFU cache <a href=\"https:\/\/leetcode.com\/problems\/lfu-cache\/description\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">leetcode<\/a> problem by implementing the Least Frequency Used algorithm using <a href=\"https:\/\/favtutor.com\/blogs\/hashing-in-data-structure\">hashing<\/a>. It is crucial for optimizing data retrieval in systems with limited resources. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Understand what is LFU cache leetcode problem with an example and how to implement it using the hashing approach.<\/p>\n","protected":false},"author":12,"featured_media":1636,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jnews-multi-image_gallery":[],"jnews_single_post":null,"jnews_primary_category":{"id":"","hide":""},"footnotes":""},"categories":[7],"tags":[14,15],"class_list":["post-1634","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-structures-algorithms","tag-dsa","tag-leetcode"],"_links":{"self":[{"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/posts\/1634","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/comments?post=1634"}],"version-history":[{"count":3,"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/posts\/1634\/revisions"}],"predecessor-version":[{"id":1684,"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/posts\/1634\/revisions\/1684"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/media\/1636"}],"wp:attachment":[{"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/media?parent=1634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/categories?post=1634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/tags?post=1634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}