<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kishorekarthick on Medium]]></title>
        <description><![CDATA[Stories by Kishorekarthick on Medium]]></description>
        <link>https://medium.com/@kishorekarthick183?source=rss-26231ecc5212------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Kishorekarthick on Medium</title>
            <link>https://medium.com/@kishorekarthick183?source=rss-26231ecc5212------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 11:11:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kishorekarthick183/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Part 2 algorithms]]></title>
            <link>https://medium.com/@kishorekarthick183/part-2-algorithms-1218b4cb6b35?source=rss-26231ecc5212------2</link>
            <guid isPermaLink="false">https://medium.com/p/1218b4cb6b35</guid>
            <dc:creator><![CDATA[Kishorekarthick]]></dc:creator>
            <pubDate>Wed, 11 Nov 2026 19:32:47 GMT</pubDate>
            <atom:updated>2026-11-11T19:32:47.699Z</atom:updated>
            <content:encoded><![CDATA[<p>segment tree + lazy segment tree</p><pre>#include &lt;bits/stdc++.h&gt;<br>using namespace std;<br><br>// this one is zero based indexing it seems cause you pass the index as <br>// this as 0 to n - 1 right ?<br>class SegmentTree {<br>private:<br>    int n;<br>    vector&lt;long long&gt; tree;<br><br>    void build(int node, int start, int end, vector&lt;int&gt;&amp; arr) {<br>        if (start == end) { // fix lowest unit number to the start or end. <br>// where both same<br>            tree[node] = arr[start];<br>            return;<br>        }<br><br>        int mid = start + (end - start) / 2;<br><br>        build(2 * node, start, mid, arr); // no return here just fix the lowest <br>// unit number<br>        build(2 * node + 1, mid + 1, end, arr);<br><br>        tree[node] = tree[2 * node] + tree[2 * node + 1];<br>    }<br><br>    void update(int node, int start, int end, int idx, int val) {<br>        if (start == end) {<br>            tree[node] = val;<br>            return;<br>        }<br><br>        int mid = start + (end - start) / 2;<br><br>        if (idx &lt;= mid) {<br>            update(2 * node, start, mid, idx, val);<br>        } else {<br>            update(2 * node + 1, mid + 1, end, idx, val);<br>        }<br><br>        tree[node] = tree[2 * node] + tree[2 * node + 1];<br>    }<br><br>    long long query(int node, int start, int end, int l, int r) {<br>// within the start and end right are the segment we are trying to search in<br>  // the l &lt;= ? &lt;= r?<br>        // No overlap<br><br>        if (r &lt; start || end &lt; l) {<br>            return 0;<br>        }<br><br>        // Complete overlap<br>        if (l &lt;= start &amp;&amp; end &lt;= r) {<br>            return tree[node];<br>        }<br><br>        // Partial overlap<br>        int mid = start + (end - start) / 2;<br><br>        long long left = query(2 * node, start, mid, l, r);<br>        long long right = query(2 * node + 1, mid + 1, end, l, r);<br><br>        return left + right;<br>    }<br><br>public:<br>    SegmentTree(vector&lt;int&gt;&amp; arr) {<br>        n = arr.size();<br>        tree.resize(4 * n);<br>        build(1, 0, n - 1, arr);<br>    }<br><br>    void update(int idx, int val) {<br>        update(1, 0, n - 1, idx, val);<br>    }<br><br>    long long query(int l, int r) {<br>        return query(1, 0, n - 1, l, r);<br>    }<br>};<br><br>int main() {<br>    vector&lt;int&gt; arr = {2, 4, 5, 7, 8, 9};<br><br>    SegmentTree st(arr);<br><br>    cout &lt;&lt; st.query(1, 4) &lt;&lt; &#39;\n&#39;;<br><br>    st.update(2, 10);<br><br>    cout &lt;&lt; st.query(1, 4) &lt;&lt; &#39;\n&#39;;<br>}</pre><p>time complexity of this code is Log(n) for point update and range query.</p><p>N for build cause you iterate via alll the nodes right ?</p><pre><br>#include &lt;bits/stdc++.h&gt;<br>using namespace std;<br><br>class LazySegmentTree {<br>private:<br>    int n;<br>    vector&lt;long long&gt; tree, lazy; // this one is one based indexing it seems<br><br>// this one is same as build in segment tree right ? <br>    void build(int node, int start, int end, vector&lt;int&gt;&amp; arr) {<br>        if (start == end) {<br>            tree[node] = arr[start];<br>            return;<br>        }<br>        int mid = start + (end - start) / 2;<br><br>        build(2 * node, start, mid, arr);<br>        build(2 * node + 1, mid + 1, end, arr);<br><br>        tree[node] = tree[2 * node] + tree[2 * node + 1];<br>    }<br><br>    // Push pending updates to children<br>    void push(int node, int start, int end) {<br>// 1. when start = end you would have a single node. which is already updated <br>// in the update function. <br><br>// 2. there is no value there to spread accross the nodes.<br>        if (lazy[node] == 0 || start == end) return;<br><br>        int mid = start + (end - start) / 2; <br>      // the value gets halved into the below 2 childs while emptying that particular.<br>        tree[2 * node] += lazy[node] * (mid - start + 1);<br>        tree[2 * node + 1] += lazy[node] * (end - mid);<br><br>        lazy[2 * node] += lazy[node];<br>        lazy[2 * node + 1] += lazy[node];<br><br>        lazy[node] = 0;<br>    }<br><br>    // Add val to every element in [l, r]<br>    void update(int node, int start, int end,<br>                int l, int r, int val) {<br><br>        // No overlap<br>        if (r &lt; start || end &lt; l) return;<br><br>        // Complete overlap<br>        if (l &lt;= start &amp;&amp; end &lt;= r) {<br>          // inside this you should have the leaf node of (end - start + 1) <br>      // which gives the accumuated value of val into that lazy array. <br><br>// it is like you dont&#39; need to walk straight to the leaf. you <br>// can just pass a message to the person denoting that this path is not saffe <br>// or this place is safe. <br><br>// early pruning concept or fixed value to be spreaded ?<br>            tree[node] += 1LL * val * (end - start + 1); // you are just fixing the tree[node] here bro . <br>            lazy[node] += val; // we just made it futurized via push<br>            return; <br>        }<br><br>        // Partial overlap<br>        push(node, start, end);<br><br>        int mid = start + (end - start) / 2;<br><br>        update(2 * node, start, mid, l, r, val);<br>        update(2 * node + 1, mid + 1, end, l, r, val);<br><br>        tree[node] = tree[2 * node] + tree[2 * node + 1];<br>    }<br><br>    // Find sum in [l, r]<br>    long long query(int node, int start, int end,<br>                    int l, int r) {<br><br>        // No overlap<br>        if (r &lt; start || end &lt; l) return 0;<br><br>        // Complete overlap<br>        if (l &lt;= start &amp;&amp; end &lt;= r) {<br>            return tree[node];<br>        }<br><br>        // Partial overlap<br>        push(node, start, end);<br><br>        int mid = start + (end - start) / 2;<br><br>        long long left = query(2 * node, start, mid, l, r);<br>        long long right = query(2 * node + 1, mid + 1, end, l, r);<br><br>        return left + right;<br>    }<br><br>public:<br>    LazySegmentTree(vector&lt;int&gt;&amp; arr) {<br>        n = arr.size() - 1;<br><br>        tree.resize(4 * n + 1, 0);<br>        lazy.resize(4 * n + 1, 0);<br><br>        build(1, 1, n, arr);<br>    }<br><br>    void update(int l, int r, int val) {<br>        update(1, 1, n, l, r, val);<br>    }<br><br>    long long query(int l, int r) {<br>        return query(1, 1, n, l, r);<br>    }<br>};<br><br>int main() {<br>    vector&lt;int&gt; arr = {0, 2, 4, 5, 7, 8, 9};<br><br>    LazySegmentTree st(arr);<br><br>    cout &lt;&lt; st.query(2, 5) &lt;&lt; &#39;\n&#39;;<br><br>    st.update(2, 5, 3);<br><br>    cout &lt;&lt; st.query(2, 5) &lt;&lt; &#39;\n&#39;;<br><br>    cout &lt;&lt; st.query(1, 6) &lt;&lt; &#39;\n&#39;;<br><br>    return 0;<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1218b4cb6b35" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part1 algorithm]]></title>
            <link>https://medium.com/@kishorekarthick183/part1-algorithm-7e949cb4096e?source=rss-26231ecc5212------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e949cb4096e</guid>
            <dc:creator><![CDATA[Kishorekarthick]]></dc:creator>
            <pubDate>Wed, 11 Nov 2026 19:01:38 GMT</pubDate>
            <atom:updated>2026-11-11T19:01:38.923Z</atom:updated>
            <content:encoded><![CDATA[<p>this is lca via binary lifting</p><pre>#include &lt;bits/stdc++.h&gt;<br>using namespace std;<br><br>const int LOG = 20;<br>const int N = 200005;<br><br>vector&lt;int&gt; adj[N];<br>int up[N][LOG];<br>int depth[N];<br><br>void dfs(int node, int parent) {<br>    up[node][0] = parent; // initial setup. ie. basecase for dp compute<br><br>    for (int i = 1; i &lt; LOG; i++) { // compute the general case<br>        up[node][i] = up[up[node][i - 1]][i - 1];<br>    }<br><br>    for (int child : adj[node]) {<br>        if (child == parent) continue;<br><br>        depth[child] = depth[node] + 1; // update the depth here<br>        dfs(child, node);<br>    }<br>}<br><br>int lca(int u, int v) {<br>    if (depth[u] &lt; depth[v]) swap(u, v); // keep the depth of u &gt; depth of v<br><br>    // Bring u to the same depth as v<br>    int diff = depth[u] - depth[v];<br><br>    for (int i = LOG - 1; i &gt;= 0; i--) {<br>      // go through all the 2 powers from (1&lt;&lt;i) till 1<br>  // bits only noted down like for 13 you have 1101 which have the up on the bits at <br>// 1,2,4 right ? <br>// we can also do like for (int i = 0; i &lt;= LOG- 1; i++)<br>        if (diff &amp; (1 &lt;&lt; i)) {<br>            u = up[u][i];<br>        }<br>    }<br><br>    if (u == v) return u; <br>// equal height of both the nodes right ? <br> // like one node is always the lowest common ancestor right ? <br>// by the above line of (u == v) <br><br><br>    // Lift both nodes until their parents become equal<br>// like they always being from eqi distance from the lowest common ancestor rigght ? <br>// now to shift to the top by taking larger steps first<br>    for (int i = LOG - 1; i &gt;= 0; i--) {<br>        if (up[u][i] != up[v][i]) {<br>            u = up[u][i];<br>            v = up[v][i];<br>        }<br>    }<br><br>// one step to get to the top right ? which is like the shape of triangle ball of <br>// down stream where the pens is the lca of the two balls. thus this teaches <br>// the final step<br><br>    return up[u][0];<br>}<br><br>int main() {<br>    int n, q;<br>    cin &gt;&gt; n &gt;&gt; q;<br><br>    for (int i = 0; i &lt; n - 1; i++) {<br>        int u, v;<br>        cin &gt;&gt; u &gt;&gt; v;<br><br>        adj[u].push_back(v);<br>        adj[v].push_back(u);<br>    }<br><br>    dfs(1, 1);<br><br>    while (q--) {<br>        int u, v;<br>        cin &gt;&gt; u &gt;&gt; v;<br><br>        cout &lt;&lt; lca(u, v) &lt;&lt; &#39;\n&#39;;<br>    }<br>}</pre><p>Ok lets come to the time complexity ?</p><p>LCA block -&gt; LoG(N)</p><p>dfs block -&gt; N log(N) cause you consider N nodes to be traversed for each of the node you process the LOG(N) times to its ancestor computation</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e949cb4096e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Using REST for Microservices: Why You Need gRPC in 2026]]></title>
            <link>https://medium.com/@kishorekarthick183/stop-using-rest-for-microservices-why-you-need-grpc-in-2026-060f73839552?source=rss-26231ecc5212------2</link>
            <guid isPermaLink="false">https://medium.com/p/060f73839552</guid>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Kishorekarthick]]></dc:creator>
            <pubDate>Tue, 18 Aug 2026 17:46:43 GMT</pubDate>
            <atom:updated>2026-08-18T17:46:43.243Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are still building internal microservices using REST and JSON, you are leaving performance, network bandwidth, and developer sanity on the table.</p><p>While REST is the undisputed king for public-facing APIs, it was never designed for low-latency, high-throughput communication between internal services. That is where <strong>gRPC</strong> comes in.</p><p>In this post, we will look at what gRPC is, why it beats REST for internal service communication, and how to write your first gRPC service in less than 5 minutes.</p><p>The Problem with REST in Microservices</p><p>In a microservice architecture, a single user request can trigger dozens of internal API calls between services. When using traditional REST, you face three major bottlenecks:</p><ol><li><strong>Text-Based Overhead:</strong> JSON is human-readable but incredibly inefficient for machines to parse and transmit.</li><li><strong>HTTP/1.1 Limitations:</strong> Traditional REST APIs open a new TCP connection for requests or suffer from head-of-line blocking, slowing down communication.</li><li><strong>No Strict Contracts:</strong> API changes easily break downstream services because JSON payloads lack strict type safety.</li></ol><p>What is gRPC?</p><p>Created by Google, <strong>gRPC</strong> (Google Remote Procedure Call) is a high-performance, open-source RPC framework.</p><p>Instead of hitting a URL endpoint like /api/v1/users, gRPC lets a client service directly call a method on a server service on a completely different machine <strong>as if it were a local function call</strong>.</p><pre>[ Client Service ] ---&gt; userService.GetUser() ---&gt; [ Server Service ]</pre><p>Use code with caution.</p><p>gRPC achieves blazing-fast speeds by leveraging two core technologies:</p><p><strong>1. Protocol Buffers (Protobuf)</strong></p><p>Instead of JSON, gRPC serializes data into a highly compressed binary format. It uses a .proto file to define strict data structures and service contracts. Because it is binary, payloads are up to 80% smaller than JSON, and serialization is dramatically faster.</p><p><strong>2. HTTP/2 Transport</strong></p><p>gRPC runs exclusively on HTTP/2. This introduces <strong>multiplexing</strong>, allowing multiple requests and responses to fly through a single TCP connection at the same time. It also supports native streaming (Server, Client, and Bidirectional).</p><p><strong>REST vs. gRPC: Head-to-Head</strong></p><p><strong>Data Format</strong><br> REST → JSON (Text)<br> gRPC → Protocol Buffers (Binary)</p><p><strong>Protocol</strong><br> REST → HTTP/1.1 or HTTP/2<br> gRPC → HTTP/2</p><p><strong>Streaming</strong><br> REST → Unidirectional (SSE)<br> gRPC → Unary, Client, Server, Bidirectional</p><p><strong>API Contract</strong><br> REST → Optional (OpenAPI/Swagger)<br> gRPC → Strict &amp; Mandatory (.proto)</p><p><strong>Code Generation</strong><br> REST → Requires third-party tools<br> gRPC → Native out of the box</p><p>5-Minute Code Guide: Your First gRPC Service</p><p>Let’s look at how easy it is to define a gRPC service. Everything starts with the .proto contract file.</p><p><strong>Step 1: Define the Contract (</strong><strong>user.proto)</strong></p><pre>syntax = &quot;proto3&quot;;<br>package user;<br>// The User Service definition<br>service UserService {<br>  rpc GetUserProfile (UserRequest) returns (UserResponse);<br>}<br>// The request message containing the user&#39;s ID<br>message UserRequest {<br>  string user_id = 1;<br>}<br>// The response message containing user details<br>message UserResponse {<br>  string name = 1;<br>  string email = 2;<br>  bool is_active = 3;<br>}</pre><p><strong>Step 2: Auto-Generate the Code</strong></p><p>With gRPC, you don’t manually write boilerplate code to parse requests. You simply run the gRPC compiler tool (protoc), and it generates strongly-typed client stubs and server interfaces in your language of choice—whether that is Go, Python, Node.js, Java, or C#.</p><p><strong>Step 3: Implement the Server</strong></p><p>Your generated code handles the networking and parsing. You only need to write the actual business logic:</p><pre>// Conceptual snippet of implementing the generated interface<br>function getUserProfile(call, callback) {<br>  const userId = call.request.user_id;<br>  // Fetch from database...<br>  callback(null, { name: &quot;Alice&quot;, email: &quot;alice@example.com&quot;, is_active: true });<br>}</pre><p><strong>IMPORTANT: </strong>When to Use gRPC (And When Not To)</p><p>gRPC is incredibly powerful, but it isn’t a silver bullet.</p><p><strong>Go with gRPC for:</strong></p><ul><li><strong>Internal Microservices:</strong> Where low latency and high performance are critical.</li><li><strong>Polyglot Environments:</strong> Easily connects a Python AI service to a Go backend and a Java data pipeline.</li><li><strong>Real-time Streaming:</strong> Perfect for chat applications, live feeds, or IoT data ingestion.</li></ul><p><strong>Stick to REST for:</strong></p><ul><li><strong>Public Web APIs:</strong> Web browsers cannot easily interact with gRPC natively; REST is still the standard for external-facing consumers.</li><li><strong>Simple CRUD Apps:</strong> If performance isn’t an issue, the simplicity of JSON and REST is perfectly fine.</li></ul><p>Conclusion</p><p>Switching internal microservices from REST to gRPC is one of the highest-impact architectural decisions you can make. You get smaller payloads, lower network latency, built-in streaming, and compile-time type safety across your entire stack.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=060f73839552" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>