I know how to do it for $$f(x)=\begin{cases} 1, &\text{if }\; x \in \mathbb Q,\\ 0,&\text{if }\; x \in \mathbb Q^c,\end{cases}$$ becuase it's too easy.
But for $$f(x)=\begin{cases} x-1, &\text{if }\;x \in \mathbb Q,\\ x, &\text{if }\;x \in\mathbb Q^c, \end{cases}$$ I am not able to find $U(P,f)$ and $L(P,f)$ where $P$ is a parition of $[0,1]$.
Is there any property that I am missing to prove it?
Write $$g(x)=\begin{cases} 1,& x \in \mathbb Q\\ 0, &x \in \mathbb Q^c\end{cases},\qquad f(x)=\begin{cases} x-1, &x \in \mathbb Q\\ x, &x \in \mathbb Q^c \end{cases}.$$
Note that $f(x)=x-g(x)$. Assume that $f$ is integrable, since $h(x)=x$ is also integrable, we know that $g=h-f$ is integrable. But you have proved that $g$ is not integrable. This is a contradiction. Therefore, $f$ is not integrable.
We have used two properties of Riemannian integrals:
Any continuous fucntion is Riemannian integrable. The proof uses the uniform continuity property of continuous fucntions defined on closed intervals, see this answer. Here we use this property to show the integrability of $h$. Indeed, for this $h$, the proof will be even simpler.
Any linear combination of integrable functions is integrable.
Added. The $\epsilon-\delta$ strategy.
Notations. We use $\pi:0=x_0<x_1<\cdots<x_n=1$ to denote a partition of $[0,1]$, and use $\|\pi\|:=\max_{1\leq i\leq n}|x_i-x_{i-1}|$ to denote the mesh of $\pi$.
Lemma (Integrability of $h(x)=x$). We have $$\lim_{\|\pi\|\to0}\sum_{i=1}^n \xi_i(x_i-x_{i-1})=\frac12,$$ where $\xi_i\in[x_{i-1},x_i]$ is chosen arbitrarily.
Proof of Lemma. Firstly, if $\xi_i$ is the mid-point of $[x_{i-1},x_i]$, i.e., $\eta_i=\frac{x_{i-1}+x_i}2$, then we get a telescoping sum $$ \sum_{i=1}^n \eta_i(x_i-x_{i-1})=\sum_{i=1}^n \frac{x_{i-1}+x_i}2(x_i-x_{i-1})=\frac12.$$ On the other hand, for arbitrary $\xi_i$, we have \begin{align*} \left|\sum_{i=1}^n (\xi_i-\eta_i)(x_i-x_{i-1})\right|&\leq \sum_{i=1}^n |\xi_i-\eta_i|(x_i-x_{i-1})\\ &\leq \sum_{i=1}^n (x_i-x_{i-1})(x_i-x_{i-1})\\ &\leq \|\pi\|\sum_{i=1}^n (x_i-x_{i-1})=\|\pi\|\to0, \end{align*} as $\|\pi\|\to0$. Combining everything proves the lemma.
Now we prove the non-integrability of $f$. The proof is similar with the proof of the non-integrability of $g$. Recall that both rational numbers and irrational numbers are dense in every interval. For any partition $\pi$, we choose $\xi_i\in[x_{i-1},x_i]$ to be irrational numbers, then $$\lim_{\|\pi\|\to0}\sum_{i=1}^n f(\xi_i)(x_i-x_{i-1})=\lim_{\|\pi\|\to0}\sum_{i=1}^n \xi_i(x_i-x_{i-1})=\frac12.$$ However, if we choose $\xi_i\in[x_{i-1},x_i]$ to be rational numbers, then $$\lim_{\|\pi\|\to0}\sum_{i=1}^n f(\xi_i)(x_i-x_{i-1})=\lim_{\|\pi\|\to0}\sum_{i=1}^n (\xi_i-1)(x_i-x_{i-1})=\frac12-1=-\frac12.$$ Therefore, by definition, $f$ is not Riemannian integrable.